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

distro: Add opt-in logs support #3673

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

Conversation

ysolomchenko
Copy link

@ysolomchenko ysolomchenko commented Feb 7, 2025

Why

Fixes #3514

What

Add opt-in logs support. The user has to set OTEL_LOGS_EXPORTER env var to otlp to enable the OTLP gRPC logs exporter (default is none).

In a separate PR I will expand example with logging support.

CHANGELOG.md Show resolved Hide resolved
@pellared pellared changed the title Add opt-in logs support distro: Add opt-in logs support Feb 7, 2025
@codecov-commenter
Copy link

codecov-commenter commented Feb 7, 2025

Codecov Report

Attention: Patch coverage is 71.92982% with 16 lines in your changes missing coverage. Please review.

Project coverage is 79.43%. Comparing base (ce88a64) to head (4d94cdd).

Files with missing lines Patch % Lines
distro/exporter.go 68.96% 7 Missing and 2 partials ⚠️
distro/otel.go 74.07% 5 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3673      +/-   ##
==========================================
- Coverage   79.56%   79.43%   -0.13%     
==========================================
  Files          88       88              
  Lines        3503     3560      +57     
==========================================
+ Hits         2787     2828      +41     
- Misses        643      655      +12     
- Partials       73       77       +4     
Flag Coverage Δ
Linux 79.15% <71.92%> (-0.12%) ⬇️
Windows 75.24% <71.92%> (-0.07%) ⬇️
macOS 75.25% <71.92%> (-0.06%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@pellared pellared marked this pull request as ready for review February 7, 2025 13:41
@pellared pellared requested review from a team as code owners February 7, 2025 13:41
CHANGELOG.md Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
func newOTLPlogExporter(c *exporterConfig) (log.Exporter, error) {
ctx := context.Background()

var opts []otlploggrpc.Option
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about HTTP support?

Copy link
Contributor

@pellared pellared Feb 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is OK.
It is only needed for our trace and metrics ingest endpoints. We do not have logs ingest (sic!).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that it is worth adding a comment that SPLUNK_REALM is not supported as our Splunk Observability ingest does not support OTLP.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about sending logs to a local collector over HTTP?

Copy link
Contributor

@pellared pellared Feb 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MrAlias

We are always sending to collector using gRPC for all signals.
See:

  • func newOTLPTracesExporter(_ logr.Logger, c *exporterConfig) (trace.SpanExporter, error) {
    ctx := context.Background()
    splunkEndpoint := otlpRealmTracesEndpoint()
    if splunkEndpoint != "" {
    // Direct ingest to Splunk Observabilty Cloud using HTTP/protobuf.
    return otlptracehttp.New(ctx,
    otlptracehttp.WithEndpoint(splunkEndpoint),
    otlptracehttp.WithURLPath(otlpRealmTracesEndpointPath),
    otlptracehttp.WithHeaders(map[string]string{
    "X-Sf-Token": c.AccessToken,
    }),
    )
    }
    var opts []otlptracegrpc.Option
    if c.AccessToken != "" {
    opts = append(opts, otlptracegrpc.WithHeaders(map[string]string{
    "X-Sf-Token": c.AccessToken,
    }))
    }
    if c.TLSConfig != nil {
    tlsCreds := credentials.NewTLS(c.TLSConfig)
    opts = append(opts, otlptracegrpc.WithTLSCredentials(tlsCreds))
    } else if noneEnvVarSet(otelExporterOTLPEndpointKey, otelExporterOTLPTracesEndpointKey, splunkRealmKey) {
    // Assume that the default endpoint (local collector) is non-TLS.
    opts = append(opts, otlptracegrpc.WithTLSCredentials(insecure.NewCredentials()))
    }
    return otlptracegrpc.New(ctx, opts...)
    }
  • func newOTLPMetricsExporter(c *exporterConfig) (metric.Exporter, error) {
    ctx := context.Background()
    splunkEndpoint := otlpRealmMetricsEndpoint()
    if splunkEndpoint != "" {
    // Direct ingest to Splunk Observabilty Cloud using HTTP/protobuf.
    return otlpmetrichttp.New(ctx,
    otlpmetrichttp.WithEndpoint(splunkEndpoint),
    otlpmetrichttp.WithURLPath(otlpRealmMetricsEndpointPath),
    otlpmetrichttp.WithHeaders(map[string]string{
    "X-Sf-Token": c.AccessToken,
    }),
    )
    }
    var opts []otlpmetricgrpc.Option
    if c.AccessToken != "" {
    opts = append(opts, otlpmetricgrpc.WithHeaders(map[string]string{
    "X-Sf-Token": c.AccessToken,
    }))
    }
    if c.TLSConfig != nil {
    tlsCreds := credentials.NewTLS(c.TLSConfig)
    opts = append(opts, otlpmetricgrpc.WithTLSCredentials(tlsCreds))
    } else if noneEnvVarSet(otelExporterOTLPEndpointKey, otelExporterOTLPMetricsEndpointKey, splunkRealmKey) {
    // Assume that the default endpoint (local collector) is non-TLS.
    opts = append(opts, otlpmetricgrpc.WithTLSCredentials(insecure.NewCredentials()))
    }
    return otlpmetricgrpc.New(ctx, opts...)
    }

There was never an ask to add support for OTEL_EXPORTER_OTLP_PROTOCOL.

Maybe we can consider reusing autoexport module as a separate PR. What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused. Why do we support HTTP for the other signals?

Copy link
Contributor

@pellared pellared Feb 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// Direct ingest to Splunk Observabilty Cloud using HTTP/protobuf. 

Because back in the days ingest was not supporting gRPC.

https://github.com/signalfx/gdi-specification/blob/6981bf3249dd1466dd89fca1a73428d0c14bd451/specification/configuration.md?plain=1#L311

Even if we do support gRPC as well I heard that it is better to use http/protobuf with our backend. This is why AFAIK all our distros are using http/protobuf when SPLUNK_REALM is used. We use grpc in other cases for backwards compatibility.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even if we do support gRPC as well I heard that it is better to use http/protobuf with our backend. This is why AFAIK all our distros are using http/protobuf when SPLUNK_REALM is used. We use grpc in other cases for backwards compatibility.

Right ... so shouldn't we support HTTP? This is only adding gRPC exporters but you are saying that HTTP is preferred, right?

Copy link
Contributor

@pellared pellared Feb 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right ... so shouldn't we support HTTP? This is only adding gRPC exporters but you are saying that HTTP is preferred, right?

Ship has sailed.
It would break users that use OTEL_EXPORTER_OTLP_ENDPOINT which targets gRPC endpoints.

Reference: https://docs.splunk.com/observability/en/gdi/get-data-in/application/go/configuration/advanced-go-otel-configuration.html

Back in the days we required to default to grpc in the GDI spec...

CHANGELOG.md Outdated Show resolved Hide resolved
@pellared pellared requested a review from MrAlias February 10, 2025 14:23
@pellared

This comment was marked as resolved.

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.

Add opt-in logs support
4 participants