Skip to content

Commit

Permalink
fix: fix makefile, docs, and gitprovider receiver after port (#21)
Browse files Browse the repository at this point in the history
* fix: fix makefile, docs, and gitprovider receiver after port

* chore: add debug docs

* chore: add vscode debug to build

* docs(readme): update readme with debugging info
  • Loading branch information
adrielp authored Jul 10, 2023
1 parent a5e8270 commit 83323aa
Show file tree
Hide file tree
Showing 20 changed files with 177 additions and 143 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,9 @@
# Dependency directories (remove the comment below to include it)
# vendor/

dev-otelcol/
otelcol
build/*
!build/.vscode
!build/.vscode/*
ocb
tmp
41 changes: 41 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Makefile

CUSTOM_COL_DIR ?= $(CURDIR)/build
OCB_PATH ?= $(CURDIR)/tmp
OCB_VERSION ?= 0.80.0
OCB_URL = https://github.com/open-telemetry/opentelemetry-collector/releases/download/cmd%2Fbuilder%2F
OS := $(shell uname | tr '[:upper:]' '[:lower:]')
ARCH := $(shell uname -m)

# set ARCH var based on output
ifeq ($(ARCH),x86_64)
ARCH = amd64
endif
ifeq ($(ARCH),aarch64)
ARCH = arm64
endif

.PHONY: build
build: check_prep
$(OCB_PATH)/ocb --config testconfig/manifest.yaml

.PHONY: build-debug
build-debug: check_prep
$(OCB_PATH)/ocb --config testconfig/manifest-debug.yaml

.PHONY: check_prep
check_prep:
@if [ ! -f $(OCB_PATH/ocb) ]; then make prep; fi

.PHONY: prep
prep:
@echo "Downloading OpenTelemetry Collector Build"
@mkdir -p $(OCB_PATH)
@curl -LO $(OCB_URL)v$(OCB_VERSION)/ocb_$(OCB_VERSION)_$(OS)_$(ARCH)
@mv ocb_$(OCB_VERSION)_$(OS)_$(ARCH) $(OCB_PATH)/ocb
@chmod +x $(OCB_PATH)/ocb

.PHONY: run
run: build
$(CUSTOM_COL_DIR)/otelcol-custom --config testconfig/config.yaml

23 changes: 17 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,24 @@
# otel-liatrio-contrib
# liatrio-otel-collector

A repository containing custom OpenTelemetry (otel) packages to be used when
building and configuring custom collectors.


## Quick Start

1. Create a PAT for GitHub with read access only
2. Run `export GH_USER=<user>` and `export GH_PAT=<pat>`
3. Run `make run`

> If you want to kill the terminal, `ctl+c` works well. Might just take a sec right
> now to gracefully exit.
### Debugging
To debug through `vscode`:
* run `make build-debug`
* run `cd build && code .`
* run vscode debugger for go

## OTEL Intro

OTEL is a protocol used for distributed logging, tracing, and metrics.
Expand Down Expand Up @@ -43,8 +59,3 @@ There are a few main concepts that should help you get started:
* [opentelemetry-collector-contrib/receiver/activedirectorydsreceiver at main · open-telemetry/opentelemetry-collector-contrib](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/receiver/activedirectorydsreceiver)
* [opentelemetry-collector-contrib/extension/basicauthextension at main · open-telemetry/opentelemetry-collector-contrib](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/extension/basicauthextension)

### Debugging
To debug, you'll want to open up the[dev-otelcol](./dev-otelcol) folder that
has been generated by running the `ocb --build-config testconfig/build-configl.yaml` command
(after you've updated the build config for your local paths). Then you can run
debug through VSCode.
57 changes: 0 additions & 57 deletions Taskfile.yml

This file was deleted.

17 changes: 17 additions & 0 deletions build/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch Otel Collector in debug",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${fileDirname}",
"args": ["--config", "../testconfig/config.yaml"]
}

]
}
6 changes: 3 additions & 3 deletions receiver/gitproviderreceiver/config.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

package gitproviderreceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/gitproviderreceiver"
package gitproviderreceiver // import "github.com/liatrio/liatrio-otel-collector/receiver/gitproviderreceiver"

import (
"errors"
Expand All @@ -11,8 +11,8 @@ import (
"go.opentelemetry.io/collector/confmap"
"go.opentelemetry.io/collector/receiver/scraperhelper"

"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/gitproviderreceiver/internal"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/gitproviderreceiver/internal/metadata"
"github.com/liatrio/liatrio-otel-collector/receiver/gitproviderreceiver/internal"
"github.com/liatrio/liatrio-otel-collector/receiver/gitproviderreceiver/internal/metadata"
)

const (
Expand Down
6 changes: 3 additions & 3 deletions receiver/gitproviderreceiver/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import (
"go.opentelemetry.io/collector/otelcol/otelcoltest"
"go.opentelemetry.io/collector/receiver/scraperhelper"

"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/gitproviderreceiver/internal"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/gitproviderreceiver/internal/metadata"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/gitproviderreceiver/internal/scraper/githubscraper"
"github.com/liatrio/liatrio-otel-collector/receiver/gitproviderreceiver/internal"
"github.com/liatrio/liatrio-otel-collector/receiver/gitproviderreceiver/internal/metadata"
"github.com/liatrio/liatrio-otel-collector/receiver/gitproviderreceiver/internal/scraper/githubscraper"
)

func TestLoadConfig(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion receiver/gitproviderreceiver/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

//go:generate mdatagen metadata.yaml

package gitproviderreceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/gitproviderreceiver"
package gitproviderreceiver // import "github.com/liatrio/liatrio-otel-collector/receiver/gitproviderreceiver"
8 changes: 4 additions & 4 deletions receiver/gitproviderreceiver/factory.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

package gitproviderreceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/gitproviderreceiver"
package gitproviderreceiver // import "github.com/liatrio/liatrio-otel-collector/receiver/gitproviderreceiver"

import (
"context"
Expand All @@ -14,9 +14,9 @@ import (
"go.opentelemetry.io/collector/receiver"
"go.opentelemetry.io/collector/receiver/scraperhelper"

"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/gitproviderreceiver/internal"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/gitproviderreceiver/internal/metadata"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/gitproviderreceiver/internal/scraper/githubscraper"
"github.com/liatrio/liatrio-otel-collector/receiver/gitproviderreceiver/internal"
"github.com/liatrio/liatrio-otel-collector/receiver/gitproviderreceiver/internal/metadata"
"github.com/liatrio/liatrio-otel-collector/receiver/gitproviderreceiver/internal/scraper/githubscraper"
)

// This file implements a factory for the git provider receiver
Expand Down
2 changes: 1 addition & 1 deletion receiver/gitproviderreceiver/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"go.opentelemetry.io/collector/consumer/consumertest"
"go.opentelemetry.io/collector/receiver/receivertest"

"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/gitproviderreceiver/internal"
"github.com/liatrio/liatrio-otel-collector/receiver/gitproviderreceiver/internal"
)

var creationSet = receivertest.NewNopCreateSettings()
Expand Down
2 changes: 1 addition & 1 deletion receiver/gitproviderreceiver/go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/open-telemetry/opentelemetry-collector-contrib/receiver/gitproviderreceiver
module github.com/liatrio/liatrio-otel-collector/receiver/gitproviderreceiver

go 1.19

Expand Down
2 changes: 1 addition & 1 deletion receiver/gitproviderreceiver/internal/scraper.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

package internal // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/gitproviderreceiver/internal"
package internal // import "github.com/liatrio/liatrio-otel-collector/receiver/gitproviderreceiver/internal"

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

package githubscraper // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/gitproviderreceiver/internal/scraper/githubscraper"
package githubscraper // import "github.com/liatrio/liatrio-otel-collector/receiver/gitproviderreceiver/internal/scraper/githubscraper"

import (
"go.opentelemetry.io/collector/config/confighttp"

"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/gitproviderreceiver/internal"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/gitproviderreceiver/internal/metadata"
"github.com/liatrio/liatrio-otel-collector/receiver/gitproviderreceiver/internal"
"github.com/liatrio/liatrio-otel-collector/receiver/gitproviderreceiver/internal/metadata"
)

// Config relating to Github Metric Scraper.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
"go.opentelemetry.io/collector/receiver"
"go.opentelemetry.io/collector/receiver/scraperhelper"

"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/gitproviderreceiver/internal"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/gitproviderreceiver/internal/metadata"
"github.com/liatrio/liatrio-otel-collector/receiver/gitproviderreceiver/internal"
"github.com/liatrio/liatrio-otel-collector/receiver/gitproviderreceiver/internal/metadata"
)

// This file implements factory for the GitHub Scraper as part of the Git Provider Receiver
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

package githubscraper // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/gitproviderreceiver/internal/scraper/githubscraper"
package githubscraper // import "github.com/liatrio/liatrio-otel-collector/receiver/gitproviderreceiver/internal/scraper/githubscraper"

import (
"context"
Expand All @@ -17,7 +17,7 @@ import (
"go.opentelemetry.io/collector/receiver"
"go.uber.org/zap"

"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/gitproviderreceiver/internal/metadata"
"github.com/liatrio/liatrio-otel-collector/receiver/gitproviderreceiver/internal/metadata"
)

var (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

package githubscraper // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/gitproviderreceiver"
package githubscraper // import "github.com/liatrio/liatrio-otel-collector/receiver/gitproviderreceiver"
40 changes: 0 additions & 40 deletions testconfig/builder-config.yaml

This file was deleted.

34 changes: 17 additions & 17 deletions testconfig/config.yaml
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
#extensions:
# basicauth/server:
# client_auth:
# username: "cn=admin,dc=example,dc=org"
# password: admin
extensions:
basicauth/github:
client_auth:
username: ${env:GH_USER}
password: ${env:GH_PAT}

receivers:
otlp:
protocols:
grpc:
github:
interval: 10s

gitprovider:
initial_delay: 1s
collection_interval: 60s
scrapers:
github:
github_org: adrielp
auth:
authenticator: basicauth/github

ldap:
interval: 10s
search_filter: "(objectclass=*)"
endpoint: "localhost"
# TODO: use basic auth
#user: "cn=admin,dc=example,dc=org"
#pw: "admin"
base_dn: "dc=example,dc=org"
ignore_tls: true

Expand All @@ -32,17 +37,12 @@ exporters:
insecure: true

service:
extensions: [basicauth/github]
pipelines:
metrics:
receivers: [otlp, github]
#receivers: [otlp, github]
#receivers: [ldapreceiver]
receivers: [otlp, gitprovider]
processors: []
exporters: [logging]
#traces:
# receivers: [otlp]
# processors: []
# exporters: [jaeger, logging]
telemetry:
logs:
level: debug
Loading

0 comments on commit 83323aa

Please sign in to comment.