Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Otlp support #422

Open
wants to merge 73 commits into
base: main
Choose a base branch
from
Open

Otlp support #422

wants to merge 73 commits into from

Conversation

Vibaswan
Copy link
Collaborator

@Vibaswan Vibaswan commented May 4, 2023

This PR is currently work in progress for the OTLP support in openapiart

Fixes #434
Fixes #435

First Step taken is to implement telemetry in go-snappi

Things done till now

  • Added Infrastructure for users to provide collector endpoint, exporter transport etc.
  • Added infrastructure by which users can create custom span, with attributes , set span status , set root context etc.
  • The generated SDK (Go/Python) automatically generates child spans for GRPC/HTTP communication internally provided the user has provided endpoint.
  • HTTP as well GRPC transport instrumentation.
  • Support for both HTTP and GRPC transport communication with the collector.
  • Added support so that users can provide their own custom span Processors for formatting spans. (Would be need by Controller as well)

Things to be done

  • Finalize the versions of python to support OTLP
  • Finalize whether to drop go 1.17 support
  • Explore if the context mapping of the controller can be shift to go-snappi itself

Sample Scripts.

Note: FYI the sample scripts were run from openapiart to otg-hw just to showcase the use-cases, as openapiart has its own sample model the set config error out

No custom Span provided by the user

func TestTelemetry(t *testing.T) {
	api := gosnappi.NewApi()
	api.NewGrpcTransport().SetLocation("10.66.47.117:5001")
	
        // start basically creates the trace provider which is a pipe keeping hold of the telemetry data
        tel, err := api.Telemetry().WithExporterEndPoint("10.66.47.117:4318").Start()
	if err != nil {
		t.Log(err)
	}
        // this is a mandatory step in the script if using telemetry, as it will stop the tracing and shut down the tracer
        // cannot be called automatically from the SDK as we don't know the when the user wants to stop it 
	defer tel.Stop()
	// NewFullyPopulatedPrefixConfig is just a dummy func here , actual config will be built here
        config := NewFullyPopulatedPrefixConfig(api)
	resp, err := api.SetConfig(config)
}

Python Sample script:

import snappi

api = snappi.api(location="10.66.47.117:5001", transport="grpc", verify=False,
                 telemetry_collector_endpoint="http://10.66.47.117:4318/v1/traces")

with api.tracer().start_as_current_span("test-telemetry"):
    # perform api calls for rest of the script

# scope of span ends
print("test passed")

Note: nomenclature for the functions are not finalized

Jaeger visualization

image

When custom Span is added by the user

func TestTelemetry(t *testing.T) {
	api := gosnappi.NewApi()
	api.NewGrpcTransport().SetLocation("10.66.47.117:5001")
	tel, err := api.Telemetry().WithExporterEndPoint("10.66.47.117:4318").StartTracing()
	if err != nil {
		t.Log(err)
	}
	defer tel.StopTracing()
       
        // adding custom span from the script
	ctx, span := tel.NewSpan(context.Background(), "test-telemetry")
	// generally if we are adding a span we want the SDK to generate child spans for this custom span.
	// so that its easier to visualize.
	// That's why we need to set the root context so that the SDK can treat it as parent and generate the rest of the child spans 
        tel.WithRootContext(ctx)
	defer tel.CloseSpan(span)

        // NewFullyPopulatedPrefixConfig is just a dummy func here , actual config will be built here
	config := NewFullyPopulatedPrefixConfig(api)
	resp, err := api.SetConfig(config)
}

Jaeger visualization

image

Current Challenges

@Vibaswan Vibaswan changed the title WIP: Otlp support Otlp support Oct 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Telemetry Support for go-snappi Support Telemetry in sanppi
4 participants