1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2026-06-03 18:35:08 +02:00

75 Commits

Author SHA1 Message Date
Robert Pająk f593185679 exporters/otlp: default max request size to 64 MiB (#8365)
Per https://github.com/open-telemetry/opentelemetry-proto/pull/782 where
we agreed to have 64 MiB as the default limit.
2026-05-26 21:00:40 +02:00
Tyler Yahn 442cdbdd94 Generate and upgrade to semconv/v1.41.0 (#8324)
Fix https://github.com/open-telemetry/opentelemetry-go/issues/8299

Relevant upstream v1.41.0 release notes:

> ### 🛑 Breaking changes 🛑
> 
> - `graphql`: Change `graphql.document` attribute requirement level
from Recommended to Opt-In due to sensitive data, cardinality, and size
concerns
([#2985](https://github.com/open-telemetry/semantic-conventions/issues/2985))
> - `process`: Move process.executable to its own entity.
([#3535](https://github.com/open-telemetry/semantic-conventions/issues/3535))
> - `process`: Update requirement levels for process attributes to
ensure consistent identification and description across platforms.
([#864](https://github.com/open-telemetry/semantic-conventions/issues/864))
> - `rpc`: Remove `client.address` and `client.port` attributes from RPC
server spans.
([#3487](https://github.com/open-telemetry/semantic-conventions/issues/3487),
[#3488](https://github.com/open-telemetry/semantic-conventions/issues/3488))
> 
> ### 💡 Enhancements 💡
> 
> - `Go`: Add opt-in go.memory.gc.pause.duration histogram metric.
([#3353](https://github.com/open-telemetry/semantic-conventions/issues/3353))
> - `deployment`: Stabilize `deployment.environment.name` attribute.
([#3339](https://github.com/open-telemetry/semantic-conventions/issues/3339))
> - `deployment`: Add enum values for `deployment.environment.name`
attribute.
([#2910](https://github.com/open-telemetry/semantic-conventions/issues/2910))
> - `go`: Add the go.cpu.time opt-in metric, and add
go.cpu.detailed_state and go.memory.detailed_type attributes to CPU and
memory metrics respectively with wildcard values.
([#3354](https://github.com/open-telemetry/semantic-conventions/issues/3354))
> - `go`: Add the opt-in go.memory.gc.cycles metric.
([#3353](https://github.com/open-telemetry/semantic-conventions/issues/3353))
> - `telemetry`: Promote `telemetry.distro.name` and
`telemetry.distro.version` attributes to 'stable'.
([#3650](https://github.com/open-telemetry/semantic-conventions/issues/3650))

This PR also:
- fixes semconv migration generation to ignore unexported declarations
when computing renames/removals
- upgrades repo imports, depguard, docs, templates, and schema URL
expectations to `go.opentelemetry.io/otel/semconv/v1.41.0`
- adds missing generated-file headers to semconvkit templates and
regenerates the affected `v1.41.0` files via `TAG="v1.41.0" make
semconv-generate`

---------

Co-authored-by: David Ashpole <dashpole@google.com>
2026-05-14 14:06:05 -04:00
Robert Pająk b4e15cd1c7 Add MaxRequestSize option to OTLP exporters (#8157)
Per https://github.com/open-telemetry/opentelemetry-proto/pull/782

- Introduce WithMaxRequestSize option for OTLP exporters to set a limit
on the size of serialized export requests.
- Implement logic in the HTTP and gRPC clients to check the request
size against the configured maximum before compression and sending.
- The default configuration is that the maximum request size is 32 MiB.
2026-04-23 22:12:44 +02:00
Robert Pająk fa9276b15e exporters: support SLICE attributes (#8216)
Fixes #8162

Follow-up to #8153 for `attribute.SLICE`.

Add end-to-end exporter handling for `attribute.SLICE` in the remaining
paths that still treated it as invalid or relied on fallback formatting.

Changes:

- encode `attribute.SLICE` as OTLP `AnyValue_ArrayValue` for trace, log,
and metric transforms
- serialize Zipkin `SLICE` attributes using the non-OTLP AnyValue string
representation
- add trace-side coverage for recursive `convAttrValue` slice conversion
2026-04-20 11:03:34 +02:00
Tyler Yahn b1284dbfaa Support BYTESLICE attributes across trace and exporter paths (#8153)
Fixes https://github.com/open-telemetry/opentelemetry-go/issues/8164

Supersedes #8042 which does not address the `trace` or `zipkin`
packages, and has unrelated support changes.

Add end-to-end handling for `attribute.BYTESLICE` in the remaining trace
and exporter paths that still dropped, invalidated, or stringified byte
slice attributes.

This change:

- preserves byte slice attributes in `trace/auto`
- encodes byte slice attributes as OTLP `AnyValue_BytesValue` in trace,
log, and metric transforms
- serializes Zipkin byte slice attributes as JSON arrays of byte values
- adds regression tests for each updated path

## Problem

`attribute.BYTESLICE` is public, but several downstream conversions
still did not handle it correctly:

- `trace/auto` dropped byte slice attributes during conversion
- OTLP trace, log, and metric transforms fell through to their invalid
default handling
- Zipkin fell back to `Value.Emit()`, which produced a base64 string
rather than an explicit byte-array representation

That made `BYTESLICE` unusable or inconsistent depending on the export
path.

## Changes

### Trace

- Handle `attribute.BYTESLICE` in `trace/auto` by converting it to an
internal telemetry bytes value.
- Add a regression test covering byte slice conversion.

### OTLP

- Handle `attribute.BYTESLICE` in:
  - trace attribute transform
  - log gRPC attribute transform
  - log HTTP attribute transform
  - metric HTTP attribute transform
  - metric gRPC attribute transform
- Update the shared log and metric transform templates so generated
outputs stay aligned.
- Add regression tests for the trace transform, both log transform
outputs, and both metric transform outputs.

### Zipkin

- Handle `attribute.BYTESLICE` explicitly in Zipkin tag serialization.
- Serialize byte slices as JSON arrays of byte values instead of base64
text.
- Add a regression test for Zipkin byte slice serialization.

---------

Co-authored-by: Robert Pająk <pellared@hotmail.com>
2026-04-09 14:04:03 -07:00
Robert Pająk f4da59e651 attribute: change INVALID Type to EMPTY and mark INVALID as deprecated (#8038)
Fixes https://github.com/open-telemetry/opentelemetry-go/issues/7932

Noticeable comment from previous PR:
https://github.com/open-telemetry/opentelemetry-go/pull/7942#discussion_r2913179215

Print the empty value as empty string per
https://opentelemetry.io/docs/specs/otel/common/#empty-values
2026-03-12 09:43:04 +01:00
Tyler Yahn 5b5c2c5d6d Upgrade to semconv/v1.40.0 (#7991) 2026-03-04 12:13:40 +01:00
Saharsh Tibrewala 61f0e4855c Bump semconv from v1.37.0 to v1.39.0 (#7789)
Fixes #7788

---------

Co-authored-by: Damien Mathieu <42@dmathieu.com>
2026-01-21 10:42:41 +01:00
Tyler Yahn d03b03395d Check context prior to delaying retry in OTLP exporters (#7678)
Fix #7673

[Issue being
addressed](https://github.com/open-telemetry/opentelemetry-go/issues/7673#issuecomment-3618325229):

> 1.
[`fn`](https://github.com/open-telemetry/opentelemetry-go/blob/1bc9713ac6dc8cbe2fd04fd6dc716d316059eb90/exporters/otlp/otlplog/otlploggrpc/internal/retry/retry_test.go#L163-L165)
is
[called](https://github.com/open-telemetry/opentelemetry-go/blob/1bc9713ac6dc8cbe2fd04fd6dc716d316059eb90/exporters/otlp/otlplog/otlploggrpc/internal/retry/retry.go#L87)
> 2. It [returns an
error](https://github.com/open-telemetry/opentelemetry-go/blob/1bc9713ac6dc8cbe2fd04fd6dc716d316059eb90/exporters/otlp/otlplog/otlploggrpc/internal/retry/retry_test.go#L165)
> 3. The code [checks if the error is
retryable](https://github.com/open-telemetry/opentelemetry-go/blob/1bc9713ac6dc8cbe2fd04fd6dc716d316059eb90/exporters/otlp/otlplog/otlploggrpc/internal/retry/retry.go#L92),
it [always
is](https://github.com/open-telemetry/opentelemetry-go/blob/1bc9713ac6dc8cbe2fd04fd6dc716d316059eb90/exporters/otlp/otlplog/otlploggrpc/internal/retry/retry_test.go#L149)
> 4. [Time delay is
checked](https://github.com/open-telemetry/opentelemetry-go/blob/1bc9713ac6dc8cbe2fd04fd6dc716d316059eb90/exporters/otlp/otlplog/otlploggrpc/internal/retry/retry.go#L97-L108)
> - [Max elsapsed
time](https://github.com/open-telemetry/opentelemetry-go/blob/1bc9713ac6dc8cbe2fd04fd6dc716d316059eb90/exporters/otlp/otlplog/otlploggrpc/internal/retry/retry_test.go#L156-L157)
is 10 ms
> - Initial [delay is
1ms](https://github.com/open-telemetry/opentelemetry-go/blob/1bc9713ac6dc8cbe2fd04fd6dc716d316059eb90/exporters/otlp/otlplog/otlploggrpc/internal/retry/retry_test.go#L151)
>    - Delay is determined to be 1ms
>    - The program proceeds to waiting
> 5. [Wait is
called](https://github.com/open-telemetry/opentelemetry-go/blob/1bc9713ac6dc8cbe2fd04fd6dc716d316059eb90/exporters/otlp/otlplog/otlploggrpc/internal/retry/retry.go#L110-L112)
> 6. The [wait select statement is
evaluated](https://github.com/open-telemetry/opentelemetry-go/blob/1bc9713ac6dc8cbe2fd04fd6dc716d316059eb90/exporters/otlp/otlplog/otlploggrpc/internal/retry/retry.go#L127-L138)
>    - On slow systems both `case`s are true
> -
[Non-deterministically](https://go.dev/ref/spec#:~:text=If%20one%20or,communications%20can%20proceed.)
the [timer channel
`case`](https://github.com/open-telemetry/opentelemetry-go/blob/1bc9713ac6dc8cbe2fd04fd6dc716d316059eb90/exporters/otlp/otlplog/otlploggrpc/internal/retry/retry.go#L137)
is selected
> - The retry function is re-run and and second iteration is recorded
causing the failure
>    - On fast systems only the context cancel is true
>       - The retry stops here with only `1` execution

Do not rely on non-deterministic `select` statement to catch ended
context prior to waiting for a retry delay. Explicitly check the context
prior to entering the wait.

This resolves the flaky test and ensure in normal operation that
requests with canceled context are ended without having to wait for any
additional delays.
2025-12-07 10:11:36 -08:00
Tyler Yahn 14d6372a05 Add the internal/observ package to otlptracegrpc (#7404)
- Part of #7007 
- Contains a TODO tracking features added in #7401 
- This package will be used to instrument `otlptracegrpc` in a follow-up
PR

### Benchmarks

```terminal
goos: linux
goarch: amd64
pkg: go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/observ
cpu: Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
                                          │ otlptracegrpc-internal-observ.bmark.result │
                                          │                   sec/op                   │
InstrumentationExportSpans/NoError-8                                      143.8n ±  4%
InstrumentationExportSpans/PartialError-8                                 1.747µ ±  6%
InstrumentationExportSpans/FullError-8                                    1.737µ ± 11%
geomean                                                                   758.4n

                                          │ otlptracegrpc-internal-observ.bmark.result │
                                          │                    B/op                    │
InstrumentationExportSpans/NoError-8                                      0.000 ± 0%
InstrumentationExportSpans/PartialError-8                                 753.0 ± 0%
InstrumentationExportSpans/FullError-8                                    753.0 ± 0%
geomean                                                                              ¹
¹ summaries must be >0 to compute geomean

                                          │ otlptracegrpc-internal-observ.bmark.result │
                                          │                 allocs/op                  │
InstrumentationExportSpans/NoError-8                                      0.000 ± 0%
InstrumentationExportSpans/PartialError-8                                 4.000 ± 0%
InstrumentationExportSpans/FullError-8                                    4.000 ± 0%
geomean                                                                              ¹
¹ summaries must be >0 to compute geomean
```

---------

Co-authored-by: Robert Pająk <pellared@hotmail.com>
2025-10-06 11:08:29 -07:00
Dave Protasowski dee11e6ae3 Add temporality selector functions (#7434)
From: https://github.com/open-telemetry/opentelemetry-go/pull/7346

This PR exposes the default TemporalitySelector funcs that are used by
the OTel env var processing.

The reason to expose these funcs is because there is some discrepancy in
various vendor documentation on how to enable these settings using go
option args WithTemporalitySelector

https://cloud-native.slack.com/archives/C01NPAXACKT/p1757443233624599

---------

Co-authored-by: Damien Mathieu <42@dmathieu.com>
Co-authored-by: David Ashpole <dashpole@google.com>
2025-10-02 16:13:59 +02:00
Tyler Yahn 6cb0e90c0e Generate gRPC Client target parsing func (#7424)
In order to add [gRPC server attributes for exporter
observability](https://github.com/open-telemetry/semantic-conventions/blob/main/docs/otel/sdk-metrics.md#metric-otelsdkexporterspaninflight),
this information needs to be parsed into a host and port. The added
generated files provides `ParseCanonicalTarget` for this functionality.

This is added as a generated template as it is expected to be needed for
all OTLP exporters (e.g. #7404, #7353).

Split from work added to #7404 

cc @yumosx 

### Benchamarks

```
goos: linux
goarch: amd64
pkg: go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/observ
cpu: Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
                                 │ otlptracegrpc-observ-target.bmark.result │
                                 │                  sec/op                  │
ParseTarget/HostName-8                                         80.90n ±  1%
ParseTarget/HostPort-8                                         123.2n ±  4%
ParseTarget/IPv4WithoutPort-8                                  94.25n ±  2%
ParseTarget/IPv4WithPort-8                                     136.2n ±  1%
ParseTarget/IPv6Bare-8                                         195.5n ±  2%
ParseTarget/IPv6Bracket-8                                      191.2n ±  3%
ParseTarget/IPv6WithPort-8                                     128.6n ±  4%
ParseTarget/UnixSocket-8                                       15.73n ±  4%
ParseTarget/UnixAbstractSocket-8                               15.71n ±  6%
ParseTarget/Passthrough-8                                      129.3n ± 18%
geomean                                                        84.98n

                                 │ otlptracegrpc-observ-target.bmark.result │
                                 │                   B/op                   │
ParseTarget/HostName-8                                         48.00 ± 0%
ParseTarget/HostPort-8                                         48.00 ± 0%
ParseTarget/IPv4WithoutPort-8                                  16.00 ± 0%
ParseTarget/IPv4WithPort-8                                     48.00 ± 0%
ParseTarget/IPv6Bare-8                                         16.00 ± 0%
ParseTarget/IPv6Bracket-8                                      16.00 ± 0%
ParseTarget/IPv6WithPort-8                                     48.00 ± 0%
ParseTarget/UnixSocket-8                                       0.000 ± 0%
ParseTarget/UnixAbstractSocket-8                               0.000 ± 0%
ParseTarget/Passthrough-8                                      48.00 ± 0%
geomean                                                                   ¹
¹ summaries must be >0 to compute geomean

                                 │ otlptracegrpc-observ-target.bmark.result │
                                 │                allocs/op                 │
ParseTarget/HostName-8                                         1.000 ± 0%
ParseTarget/HostPort-8                                         1.000 ± 0%
ParseTarget/IPv4WithoutPort-8                                  1.000 ± 0%
ParseTarget/IPv4WithPort-8                                     1.000 ± 0%
ParseTarget/IPv6Bare-8                                         1.000 ± 0%
ParseTarget/IPv6Bracket-8                                      1.000 ± 0%
ParseTarget/IPv6WithPort-8                                     1.000 ± 0%
ParseTarget/UnixSocket-8                                       0.000 ± 0%
ParseTarget/UnixAbstractSocket-8                               0.000 ± 0%
ParseTarget/Passthrough-8                                      1.000 ± 0%
geomean                                                                   ¹
¹ summaries must be >0 to compute geomean
```
2025-09-29 07:33:08 -07:00
Flc゛ 80cb909774 refactor: replace context.Background() with t.Context()/b.Context() in tests (#7352)
Based on the Go version we currently use, the dependency already
supports 1.24+, which allows using `t.Context()` and `b.Context()` in
unit tests and benchmarks respectively.

- Enable `context-background` and `context-todo` in
[`usetesting`](https://golangci-lint.run/docs/linters/configuration/#usetesting)
- Adjust the code to support linter detection

---------

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
Co-authored-by: Tyler Yahn <codingalias@gmail.com>
Co-authored-by: Damien Mathieu <42@dmathieu.com>
2025-09-23 09:52:45 +02:00
Tyler Yahn 6180f833bc Return partial OTLP export errors to the caller (#7372)
Fix #7370 

Do not pass relevant errors for the operation of the export to the
`otel.ErrorHandler`. Instead, include them in the error returned to the
caller.
2025-09-18 13:08:25 -07:00
Tyler Yahn 5358fd737d Upgrade semconv dependencies to v1.37.0 (#7260)
Resolve https://github.com/open-telemetry/opentelemetry-go/issues/7255
2025-08-28 11:29:52 +02:00
Tyler Yahn 4b2bef6dd9 [chore] Upgrade semconv pkg use to v1.36.0 (#7237)
Fix #7236
2025-08-25 16:33:34 +02:00
Mikhail Mazurskiy 5e1c62a2d5 Modernize (#7089)
Use
https://pkg.go.dev/golang.org/x/tools/gopls/internal/analysis/modernize
to update code to new style.

---------

Co-authored-by: Flc゛ <four_leaf_clover@foxmail.com>
Co-authored-by: Damien Mathieu <42@dmathieu.com>
2025-07-29 10:19:11 +02:00
Sam Xie a4055c21bc Use the cause of the context error in OTLP retry (#6898)
Part of #6588

For a demo code like this

```go
package main

import (
	"context"
	"fmt"
	"log"
	"time"

	"go.opentelemetry.io/otel"
	"go.opentelemetry.io/otel/exporters/otlp/otlptrace"
	"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc"
	sdktrace "go.opentelemetry.io/otel/sdk/trace"
)

func main() {
	ctx := context.Background()

	exp, err := newExporter(ctx)
	if err != nil {
		log.Fatalf("failed to initialize trace exporter: %v", err)
	}

	tp, err := newTracerProvider(exp)
	if err != nil {
		log.Fatalf("failed to initialize trace provider: %v", err)
	}

	defer func() { _ = tp.Shutdown(ctx) }()

	otel.SetTracerProvider(tp)
	generateSpan()

	select {}
}

func generateSpan() {
	log.Println("Generating a dummy span")
	_, span := otel.Tracer("").Start(context.Background(), "dummy")
	defer span.End()
}

func newTracerProvider(exp sdktrace.SpanExporter) (*sdktrace.TracerProvider, error) {
	return sdktrace.NewTracerProvider(
		sdktrace.WithBatcher(exp),
	), nil
}

func newExporter(ctx context.Context) (*otlptrace.Exporter, error) {
	traceExporter, err := otlptrace.New(
		ctx,
		otlptracegrpc.NewClient(
			otlptracegrpc.WithEndpoint("127.0.0.1:4317"),
			otlptracegrpc.WithInsecure(),
			otlptracegrpc.WithRetry(otlptracegrpc.RetryConfig{
				Enabled:         true,
				InitialInterval: 1 * time.Second,
				MaxInterval:     30 * time.Second,
				MaxElapsedTime:  time.Minute,
			}),
		),
	)
	if err != nil {
		return nil, fmt.Errorf("failed to create trace exporter: %w", err)
	}

	return traceExporter, nil
}
```

the error result from

```
traces export: context deadline exceeded: rpc error: code = Unavailable desc = connection error: desc = "transport: Error while dialing: dial tcp 127.0.0.1:4317: connect: connection refused"
```

become

```
traces export: exporter export timeout: rpc error: code = Unavailable desc = connection error: desc = "transport: Error while dialing: dial tcp 127.0.0.1:4317: connect: connection refused"
```
2025-06-12 19:02:35 +02:00
Matt Quinn 1636bcdd1d fix(otlptrace,otlpmetric): remove endpoint URL path cleaning (#6710)
When setting an explicit OTLP traces endpoint URL (via
`otlptracehttp.WithEndpointURL` or the
`OTEL_EXPORTER_OTLP_TRACES_ENDPOINT` environment variable), any given
trailing slash is stripped. This makes it impossible to export traces to
an endpoint requiring a trailing slash. It also conflicts with [the
spec](https://opentelemetry.io/docs/specs/otel/protocol/exporter/#endpoint-urls-for-otlphttp):

> For the per-signal variables (OTEL_EXPORTER_OTLP_\<signal\>_ENDPOINT),
the URL MUST be used as-is without any modification. The only exception
is that if an URL contains no path part, the root path / MUST be used
(see [Example
2](https://opentelemetry.io/docs/specs/otel/protocol/exporter/#example-2)).

This stripping happens due to [the use of `path.Clean` in
`otlpconfig.cleanPath`](https://github.com/open-telemetry/opentelemetry-go/blob/b4b461d050f1d0f5bda89ddac718180162120606/exporters/otlp/otlptrace/otlptracehttp/internal/otlpconfig/options.go#L97).
From [the `path.Clean` docs](https://pkg.go.dev/path#Clean):

> The returned path ends in a slash only if it is the root "/".

Fixes #6709.
2025-06-03 07:12:49 +02:00
Tyler Yahn bf8af6f113 Upgrade semconv to v1.34.0 for OTLP templates (#6828) 2025-05-28 10:05:46 -07:00
Robert Pająk 5cd1611cda otlptracehttp: Add WithHTTPClient option (#6751)
Follows https://github.com/open-telemetry/opentelemetry-go/pull/6688

Towards (for OTLP trace exporter):
- https://github.com/open-telemetry/opentelemetry-go/issues/4536
- https://github.com/open-telemetry/opentelemetry-go/issues/5129
- https://github.com/open-telemetry/opentelemetry-go/issues/2632
2025-05-13 21:06:01 +02:00
Robert Pająk b66542529a otlpmetrichttp: Add WithHTTPClient option (#6752)
Follows https://github.com/open-telemetry/opentelemetry-go/pull/6688

Towards (for OTLP metric exporter):
- https://github.com/open-telemetry/opentelemetry-go/issues/4536
- https://github.com/open-telemetry/opentelemetry-go/issues/5129
- https://github.com/open-telemetry/opentelemetry-go/issues/2632
2025-05-13 20:58:06 +02:00
Sean Liao 1d8824889c all: match go conventions for generated code (#6731)
Go documents the following regex pattern
for identifying generated code:
^// Code generated .* DO NOT EDIT\.$

This convention is used go APIs and tooling.
References:
https://pkg.go.dev/go/ast#IsGenerated
https://pkg.go.dev/cmd/go#hdr-Generate_Go_files_by_processing_source

Co-authored-by: Damien Mathieu <42@dmathieu.com>
2025-05-05 09:41:12 +02:00
Damien Mathieu b9e3f32a83 Relax grpc errors to allow for upgrade (#6685)
#6679 is changing the gRPC errors, which fails our tests.
This change allows those tests to pass so the upgrade can happen.
2025-04-23 09:53:02 +02:00
Tyler Yahn 7512a2be2e Add the golines golangci-lint formatter (#6513)
Ensure consistent line wrapping (<= 120 characters) within the project.
2025-03-30 03:46:44 -07:00
renovate[bot] 590bcee71b fix(deps): update module github.com/golangci/golangci-lint to v2 (#6499)
This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
|
[github.com/golangci/golangci-lint](https://redirect.github.com/golangci/golangci-lint)
| `v1.64.8` -> `v2.0.2` |
[![age](https://developer.mend.io/api/mc/badges/age/go/github.com%2fgolangci%2fgolangci-lint/v2.0.2?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/go/github.com%2fgolangci%2fgolangci-lint/v2.0.2?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/go/github.com%2fgolangci%2fgolangci-lint/v1.64.8/v2.0.2?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/go/github.com%2fgolangci%2fgolangci-lint/v1.64.8/v2.0.2?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>golangci/golangci-lint
(github.com/golangci/golangci-lint)</summary>

###
[`v2.0.2`](https://redirect.github.com/golangci/golangci-lint/blob/HEAD/CHANGELOG.md#v202)

[Compare
Source](https://redirect.github.com/golangci/golangci-lint/compare/v2.0.1...v2.0.2)

1.  Misc.
    -   Fixes flags parsing for formatters
    -   Fixes the filepath used by the exclusion `source` option
2.  Documentation
    -   Adds a section about flags migration
    -   Cleaning pages with v1 options

###
[`v2.0.1`](https://redirect.github.com/golangci/golangci-lint/blob/HEAD/CHANGELOG.md#v201)

[Compare
Source](https://redirect.github.com/golangci/golangci-lint/compare/v2.0.0...v2.0.1)

1.  Linters/formatters bug fixes
    -   `golines`: fix settings during linter load
2.  Misc.
    -   Validates the `version` field before the configuration
    -   `forbidigo`: fix migration

###
[`v2.0.0`](https://redirect.github.com/golangci/golangci-lint/blob/HEAD/CHANGELOG.md#v200)

[Compare
Source](https://redirect.github.com/golangci/golangci-lint/compare/v1.64.8...v2.0.0)

1.  Enhancements
- 🌟 New `golangci-lint fmt` command with dedicated formatter
configuration
(https://golangci-lint.run/welcome/quick-start/#formatting)
- ♻️ New `golangci-lint migrate` command to help migration from v1 to v2
(cf. [Migration
guide](https://golangci-lint.run/product/migration-guide/#command-migrate))
- ⚠️ New default values (cf. [Migration
guide](https://golangci-lint.run/product/migration-guide/))
- ⚠️ No exclusions by default (cf. [Migration
guide](https://golangci-lint.run/product/migration-guide/#issuesexclude-use-default))
- ⚠️ New default sort order (cf. [Migration
guide](https://golangci-lint.run/product/migration-guide/#outputsort-order))
- 🌟 New option `run.relative-path-mode` (cf. [Migration
guide](https://golangci-lint.run/product/migration-guide/#runrelative-path-mode))
- 🌟 New linters configuration (cf. [Migration
guide](https://golangci-lint.run/product/migration-guide/#linters))
- 🌟 New output format configuration (cf. [Migration
guide](https://golangci-lint.run/product/migration-guide/#output))
- 🌟 New `--fast-only` flag (cf. [Migration
guide](https://golangci-lint.run/product/migration-guide/#lintersfast))
- 🌟 New option `linters.exclusions.warn-unused` to log a warning if an
exclusion rule is unused.
2.  New linters/formatters
    -   Add `golines` formatter https://github.com/segmentio/golines
3.  Linters new features
- ⚠️ Merge `staticcheck`, `stylecheck`, `gosimple` into one linter
(`staticcheck`) (cf. [Migration
guide](https://golangci-lint.run/product/migration-guide/#lintersenablestylecheckgosimplestaticcheck))
    -   `go-critic`: from 0.12.0 to 0.13.0
- `gomodguard`: from 1.3.5 to 1.4.1 (block explicit indirect
dependencies)
    -   `nilnil`: from 1.0.1 to 1.1.0 (new option: `only-two`)
- `perfsprint`: from 0.8.2 to 0.9.1 (checker name in the diagnostic
message)
    -   `staticcheck`: new `quickfix` set of rules
- `testifylint`: from 1.5.2 to 1.6.0 (new options: `equal-values`,
`suite-method-signature`, `require-string-msg`)
- `wsl`: from 4.5.0 to 4.6.0 (new option: `allow-cuddle-used-in-block`)
4.  Linters bug fixes
    -   `bidichk`: from 0.3.2 to 0.3.3
    -   `errchkjson`: from 0.4.0 to 0.4.1
    -   `errname`: from 1.0.0 to 1.1.0
    -   `funlen`: fix `ignore-comments` option
    -   `gci`: from 0.13.5 to 0.13.6
    -   `gosmopolitan`: from 1.2.2 to 1.3.0
    -   `inamedparam`: from 0.1.3 to 0.2.0
    -   `intrange`: from 0.3.0 to 0.3.1
    -   `protogetter`: from 0.3.9 to 0.3.12
- `unparam`: from
[`8a5130c`](https://redirect.github.com/golangci/golangci-lint/commit/8a5130ca722f)
to
[`0df0534`](https://redirect.github.com/golangci/golangci-lint/commit/0df0534333a4)
5.  Misc.
- 🧹 Configuration options renaming (cf. [Migration
guide](https://golangci-lint.run/product/migration-guide/))
- 🧹 Remove options (cf. [Migration
guide](https://golangci-lint.run/product/migration-guide/))
- 🧹 Remove flags (cf. [Migration
guide](https://golangci-lint.run/product/migration-guide/))
- 🧹 Remove alternative names (cf. [Migration
guide](https://golangci-lint.run/product/migration-guide/#alternative-linter-names))
- 🧹 Remove or replace deprecated elements (cf. [Migration
guide](https://golangci-lint.run/product/migration-guide/))
    -   Adds an option to display some commands as JSON:
        -   `golangci-lint config path --json`
        -   `golangci-lint help linters --json`
        -   `golangci-lint help formatters --json`
        -   `golangci-lint linters --json`
        -   `golangci-lint formatters --json`
        -   `golangci-lint version --json`
6.  Documentation
- [Migration guide](https://golangci-lint.run/product/migration-guide/)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR is behind base branch, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR was generated by [Mend Renovate](https://mend.io/renovate/).
View the [repository job
log](https://developer.mend.io/github/open-telemetry/opentelemetry-go).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOS4yMDcuMSIsInVwZGF0ZWRJblZlciI6IjM5LjIwNy4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJTa2lwIENoYW5nZWxvZyIsImRlcGVuZGVuY2llcyJdfQ==-->

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Tyler Yahn <codingalias@gmail.com>
2025-03-26 10:46:44 -07:00
ian 11cea3495c feat(retry): update backoff to v5, fix the breaking changes in that version (#6419)
- Remove unsupported fields in v5: `MaxElapsedTime`, `Stop` and `Clock`
- Use `time.Now()` and `time.Since()` to manually track elapsed time

Fix #6417

---------

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
2025-03-15 08:15:56 -07:00
Robert Pająk ae7ac48ebf otlplog: Emit Record.EventName field (#6211)
Fixes https://github.com/open-telemetry/opentelemetry-go/issues/6185
2025-01-25 22:23:10 +01:00
Matthieu MOREL 74937a2952 [chore]: enable all rules of perfsprint (#5978)
#### Description

[perfsprint](https://github.com/catenacyber/perfsprint) is a linter for
performance, aiming at usages of fmt.Sprintf which have faster
alternatives.

Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2024-11-18 10:04:50 +01:00
Damien Mathieu 2c15a77942 Fix lint issues for golangci-lint 1.62.0 (#5967)
This fixes the new lint issues brough by the golangci-lint upgrade in
https://github.com/open-telemetry/opentelemetry-go/pull/5966
2024-11-13 08:58:59 +01:00
Seva Orlov b62a3fdd25 Override insecure when endpoint URL is set (#5944)
When an endpoint is set in both Environment variable with "http" and
passed in WithEndpointURL with "https", Insecure is set to true while
the endpoint is used from WithEndpointURL.

Example
- OTEL_EXPORTER_OTLP_ENDPOINT is set to "http://env.endpoint/prefix" 
- WithEndpointURL is passed "https://someendpoint/somepath"

The real endpoint used is "http://someendpoint/somepath", which is
actually neither of both.

---------

Co-authored-by: Robert Pająk <pellared@hotmail.com>
2024-11-07 13:50:10 +01:00
Robert Pająk 2a50fab505 otlplog: Add instrumentation scope attributes (#5933)
Towards https://github.com/open-telemetry/opentelemetry-go/issues/5844
2024-10-31 12:28:11 +01:00
Robert Pająk afd1311f3e otlpmetric: Add instrumentation scope attributes (#5935)
Towards https://github.com/open-telemetry/opentelemetry-go/issues/5844
2024-10-31 11:34:44 +01:00
Tyler Yahn 86a51dc049 [chore] Remove unnecessary type declaration in templated transforms (#5906)
The type is fully defined by the switch, no need to be redundant.
2024-10-22 16:06:26 -07:00
Matthieu MOREL 6edc7a63df [chore]: enable expected-actual rule from testifylint (#5848)
Testifylint is a linter that provides best practices with the use of
testify.

This PR enables
[expected-actual](https://github.com/Antonboom/testifylint?tab=readme-ov-file#expected-actual)
rule from [testifylint](https://github.com/Antonboom/testifylint)

Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2024-09-26 12:04:33 +02:00
Matthieu MOREL d284a86fa5 [chore]: enable error-nil rule from testifylint (#5843)
Testifylint is a linter that provides best practices with the use of
testify.

This PR enables
[error-nil](https://github.com/Antonboom/testifylint?tab=readme-ov-file#error-nil)
rule from [testifylint](https://github.com/Antonboom/testifylint)

Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
Co-authored-by: Robert Pająk <pellared@hotmail.com>
2024-09-25 11:07:59 +02:00
Matthieu MOREL 62cc0c7441 [chore]: enable error-is-as rule from testifylint (#5836)
Testifylint is a linter that provides best practices with the use of
testify.

This PR enables
[error-is-as](https://github.com/Antonboom/testifylint?tab=readme-ov-file#error-is-as)
rule from [testifylint](https://github.com/Antonboom/testifylint)

Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2024-09-24 19:17:16 +02:00
Matthieu MOREL 063239fa37 [chore]: enable len and empty rules from testifylint (#5832)
#### Description

Testifylint is a linter that provides best practices with the use of
testify.

This PR enables
[empty](https://github.com/Antonboom/testifylint?tab=readme-ov-file#empty)
and
[len](https://github.com/Antonboom/testifylint?tab=readme-ov-file#len)
rules from [testifylint](https://github.com/Antonboom/testifylint)

Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2024-09-21 08:04:28 -07:00
Matthieu MOREL aef9e4fa2f [chore]: enable bool-compare rule from testifylint (#5829)
#### Description

Testifylint is a linter that provides best practices with the use of
testify.

This PR enables
[bool-compare](https://github.com/Antonboom/testifylint?tab=readme-ov-file#bool-compare)
rule from [testifylint](https://github.com/Antonboom/testifylint)

It's linter provided by golangci-lint.

Here all available rules are activated except those who require to be
fixed. This PR only fixes bool-compare so the quantity of changes stays
reasonnable for reviewers.

Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
Co-authored-by: Damien Mathieu <42@dmathieu.com>
2024-09-20 09:39:27 +02:00
pree-dew 534ce5ab09 Fix duplicate logs across resources (#5803)
1. Create scope map with resource key to map the correct log record. 
2. Add test case with different resource and scope combination

Fixes #5782 

### Benchmarks

```
goos: darwin
goarch: arm64
pkg: go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc/internal/transform
               │   old.txt   │               new.txt               │
               │   sec/op    │   sec/op     vs base                │
ResourceLogs-8   3.266µ ± 3%   1.100µ ± 5%  -66.33% (p=0.000 n=10)

               │   old.txt    │               new.txt                │
               │     B/op     │     B/op      vs base                │
ResourceLogs-8   8.297Ki ± 0%   2.430Ki ± 0%  -70.72% (p=0.000 n=10)

               │   old.txt   │              new.txt               │
               │  allocs/op  │ allocs/op   vs base                │
ResourceLogs-8   178.00 ± 0%   52.00 ± 0%  -70.79% (p=0.000 n=10)
```

---------

Co-authored-by: Sam Xie <sam@samxie.me>
2024-09-17 13:12:49 +02:00
Damien Mathieu a3c512aa95 Fix gosec overflow alerts (#5799)
To allow the golangci-lint upgrade in #5796.

---------

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
2024-09-13 09:11:50 +02:00
Nathan Baulch 506a9baf5e Fix typos (#5763) 2024-09-09 08:53:15 +02:00
Zhihan Li 83ae9bd0e3 Bugfix: OTLP exporters should not percent decode the key when parsing HEADERS env vars (#5705)
Bugfix #5623

As stated in the issue, we need to avoid parsing the key and instead
implement a validation check for it. I've added some unit tests to
verify this fix.

However, I noticed a comment at the top of this file:
```
// Code created by gotmpl. DO NOT MODIFY.
// source: internal/shared/otlp/envconfig/envconfig.go.tmpl
```
It seems that `internal/shared/otlp/envconfig/envconfig.go.tmpl` is the
source template for this file. Since this template matches
`exporters/otlp/otlptrace/otlptracegrpc/internal/envconfig/envconfig.go`,
I updated the template to maintain consistency. I’m not entirely sure if
this approach is correct, so please confirm if this is the right course
of action.

---------

Co-authored-by: Fools <54661071+Charlie-lizhihan@users.noreply.github.com>
Co-authored-by: Damien Mathieu <42@dmathieu.com>
Co-authored-by: Robert Pająk <pellared@hotmail.com>
Co-authored-by: Chester Cheung <cheung.zhy.csu@gmail.com>
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
2024-08-21 07:53:24 -07:00
Sam Xie 48f6a11b75 Correct the comment for the priority of options and environments on otlpmetric (#5641)
Part of https://github.com/open-telemetry/opentelemetry-go/issues/5379
2024-07-24 18:42:37 -07:00
Damien Mathieu 3e17ef99d6 Allow relying on InstrumentationScope in SpanStub and fix remaining deprecation issues (#5627)
Rather than the deprecated InstrumentationLibrary

This is a replacement for
https://github.com/open-telemetry/opentelemetry-go/pull/3104, as after
this, there is no usage of `instrumentation.Library` within the SDK
anymore.

---------

Co-authored-by: Robert Pająk <pellared@hotmail.com>
Co-authored-by: Sam Xie <sam@samxie.me>
2024-07-24 09:33:07 +02:00
Damien Mathieu 8f965b6b85 Add resource metrics transform benchmarks (#5602)
Co-authored-by: David Ashpole <dashpole@google.com>
2024-07-12 09:38:29 +02:00
Sam Xie aab5af16af Correct the comment for the priority of options and environments on otlptracehttp (#5584)
part of https://github.com/open-telemetry/opentelemetry-go/issues/5379
2024-07-08 18:14:06 -07:00
Sam Xie 82fe9aa1e3 Generate internal/transform in otlploggrpc (#5553)
Part of #5056

It abstracts the `transform` package from `otlploghttp` and makes it a
shared template. Then, it generates the abstracted `transform` package
into `otlploggrpc`.

For full usage of this transform package, check
https://github.com/open-telemetry/opentelemetry-go/pull/5522
2024-06-28 10:15:35 +02:00
Damien Mathieu 6d45f283c7 Add errorlint linter (#5535)
This is the last PR adding missing linters, adding
[errorlint](https://github.com/polyfloyd/go-errorlint).

Co-authored-by: Sam Xie <sam@samxie.me>
2024-06-25 10:55:00 -07:00
Damien Mathieu 3e91436a3b Add unconvert linter (#5529)
This adds the unconvert linter, and fixes every new issue related to it.

Co-authored-by: Sam Xie <sam@samxie.me>
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
2024-06-21 15:00:26 -07:00