Skip to content

Commit

Permalink
Move tracegen functionality to telemetrygen traces subcommand (#16358)
Browse files Browse the repository at this point in the history
- Copies tracegen functionality to an internal package in telemetrygen
- Moves telemetrygen config from internal to main package in order to import internal traces package
- Copies existing Github actions from tracegen for telemetrygen
- Marks tracegen module as deprecated

Link to tracking Issue: #9597

Co-authored-by: Tyler Helmuth <12352919+TylerHelmuth@users.noreply.github.com>
  • Loading branch information
liustanley and TylerHelmuth authored Jan 11, 2023
1 parent 130179c commit 5839afd
Showing 16 changed files with 1,223 additions and 24 deletions.
11 changes: 11 additions & 0 deletions .chloggen/deprecate-tracegen.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: deprecation

# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component: tracegen

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Deprecates tracegen, functionality has been moved to telemetrygen traces

# One or more tracking issues related to the change
issues: [9597]
11 changes: 11 additions & 0 deletions .chloggen/move-tracegen-functionality-to-telemetrygen.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: enhancement

# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component: telemetrygen

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Moves tracegen functionality to the telemetrygen traces subcommand, as well as the existing Github actions

# One or more tracking issues related to the change
issues: [9597]
70 changes: 70 additions & 0 deletions .github/workflows/telemetrygen.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: telemetrygen
on:
push:
branches: [ main ]
tags:
- 'v[0-9]+.[0-9]+.[0-9]+*'
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref }}
cancel-in-progress: true

jobs:
build-dev:
runs-on: ubuntu-latest
if: ${{ github.actor != 'dependabot[bot]' }}
steps:
- name: Checkout Repo
uses: actions/checkout@v3
- name: Build telemetrygen
uses: docker/build-push-action@v3
with:
context: cmd/telemetrygen
push: false
tags: ghcr.io/open-telemetry/opentelemetry-collector-contrib/telemetrygen:dev

publish-latest:
runs-on: ubuntu-latest
if: (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')) && github.repository == 'open-telemetry/opentelemetry-collector-contrib'
permissions:
packages: write
steps:
- name: Checkout Repo
uses: actions/checkout@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push telemetrygen to Github packages
uses: docker/build-push-action@v3
with:
context: cmd/telemetrygen
push: true
tags: ghcr.io/open-telemetry/opentelemetry-collector-contrib/telemetrygen:latest

publish-stable:
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v') && github.repository == 'open-telemetry/opentelemetry-collector-contrib'
permissions:
packages: write
steps:
- name: Checkout Repo
uses: actions/checkout@v3
- name: Set Release Tag
id: github_tag
run: ./.github/workflows/scripts/set_release_tag.sh
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push telemetrygen to Github packages
run: |
docker build cmd/telemetrygen -t ghcr.io/open-telemetry/opentelemetry-collector-contrib/telemetrygen:$RELEASE_TAG
docker push ghcr.io/open-telemetry/opentelemetry-collector-contrib/telemetrygen:$RELEASE_TAG
env:
RELEASE_TAG: ${{ steps.github_tag.outputs.tag }}
49 changes: 41 additions & 8 deletions cmd/telemetrygen/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# Telemetry generator for OpenTelemetry

| Status | |
| ------------------------ |-----------------|
| Stability | [development] |
| Supported signal types | traces, metrics |
| Status | |
| ------------------------ |-----------------------|
| Stability | traces [alpha] |
| | metrics [development] |
| Supported signal types | traces, metrics |

This utility simulates a client generating **traces** and **metrics**, useful for testing and demonstration purposes.

@@ -18,14 +19,46 @@ $ go install github.com/open-telemetry/opentelemetry-collector-contrib/cmd/telem
Check the [`go install` reference](https://go.dev/ref/mod#go-install) to install specific versions.


## -> Telemetrygen is in development
## Running

First, you'll need an OpenTelemetry Collector to receive the telemetry data. Follow the project's instructions for a detailed setting up guide. The following configuration file should be sufficient:

```yaml
receivers:
otlp:
protocols:
grpc:
endpoint: localhost:4317

processors:

exporters:
logging:

service:
pipelines:
traces:
receivers:
- otlp
processors: []
exporters:
- logging
```
telemetrygen traces
```
Once the OpenTelemetry Collector instance is up and running, run `telemetrygen` for your desired telemetry:

### Traces
```console
$ telemetrygen traces --otlp-insecure --duration 5s
```
telemetrygen metrics

Or, to generate a specific number of traces:
```console
$ telemetrygen traces --otlp-insecure --traces 1
```

Check `telemetrygen traces --help` for all the options.


[development]: https://github.com/open-telemetry/opentelemetry-collector#development
[alpha]: https://github.com/open-telemetry/opentelemetry-collector#alpha
Original file line number Diff line number Diff line change
@@ -13,15 +13,19 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package telemetrygen // import "github.com/open-telemetry/opentelemetry-collector-contrib/telemetrygen/internal/telemetrygen"
package main // import "github.com/open-telemetry/opentelemetry-collector-contrib/telemetrygen/internal/telemetrygen"

import (
"errors"
"os"

"github.com/spf13/cobra"

"github.com/open-telemetry/opentelemetry-collector-contrib/cmd/telemetrygen/internal/traces"
)

var tracesCfg *traces.Config

// rootCmd is the root command on which will be run children commands
var rootCmd = &cobra.Command{
Use: "telemetrygen",
@@ -35,8 +39,7 @@ var tracesCmd = &cobra.Command{
Short: "Simulates a client generating traces",
Example: "telemetrygen traces",
RunE: func(cmd *cobra.Command, args []string) error {
err := errors.New("[WIP] The 'traces' command is a work in progress, come back later")
return err
return traces.Start(tracesCfg)
},
}

@@ -54,6 +57,9 @@ var metricsCmd = &cobra.Command{
func init() {
rootCmd.AddCommand(tracesCmd, metricsCmd)

tracesCfg = new(traces.Config)
tracesCfg.Flags(tracesCmd.Flags())

// Disabling completion command for end user
// https://github.com/spf13/cobra/blob/master/shell_completions.md
rootCmd.CompletionOptions.DisableDefaultCmd = true
36 changes: 33 additions & 3 deletions cmd/telemetrygen/go.mod
Original file line number Diff line number Diff line change
@@ -2,11 +2,41 @@ module github.com/open-telemetry/opentelemetry-collector-contrib/cmd/telemetryge

go 1.18

require github.com/spf13/cobra v1.5.0
require (
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0
github.com/spf13/cobra v1.6.1
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.8.1
go.opentelemetry.io/otel v1.11.1
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.11.1
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.11.1
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.11.1
go.opentelemetry.io/otel/sdk v1.11.1
go.opentelemetry.io/otel/trace v1.11.1
go.uber.org/atomic v1.10.0
go.uber.org/zap v1.23.0
golang.org/x/time v0.2.0
google.golang.org/grpc v1.50.1
)

require (
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/cenkalti/backoff/v4 v4.1.3 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/go-logr/logr v1.2.3 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.13.0 // indirect
github.com/inconshreveable/mousetrap v1.0.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.11.1 // indirect
go.opentelemetry.io/proto/otlp v0.19.0 // indirect
go.uber.org/multierr v1.8.0 // indirect
golang.org/x/net v0.1.0 // indirect
golang.org/x/sys v0.1.0 // indirect
golang.org/x/text v0.4.0 // indirect
google.golang.org/genproto v0.0.0-20221027153422-115e99e71e1c // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

retract v0.65.0
Loading

0 comments on commit 5839afd

Please sign in to comment.