Skip to content

Commit

Permalink
Merge branch 'main' into remove_deprecated_interfaces_connector
Browse files Browse the repository at this point in the history
  • Loading branch information
atoulme committed Mar 19, 2024
2 parents 300f0bc + 7f13812 commit 181c632
Show file tree
Hide file tree
Showing 14 changed files with 202 additions and 2 deletions.
25 changes: 25 additions & 0 deletions .chloggen/deprecate-SanatizedEndpoints.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Use this changelog template to create an entry for release notes.

# 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. otlpreceiver)
component: configgrpc

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Deprecate `SanitizedEndpoint`

# One or more tracking issues or pull requests related to the change
issues: [9788]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:

# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: []
18 changes: 18 additions & 0 deletions cmd/mdatagen/internal/samplereceiver/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,24 @@ The metric will be will be removed soon.
| ---- | ----------- | ---------- | ----------------------- | --------- |
| s | Sum | Double | Delta | false |

### metric.input_type

Monotonic cumulative sum int metric with string input_type enabled by default.

| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic |
| ---- | ----------- | ---------- | ----------------------- | --------- |
| s | Sum | Int | Cumulative | true |

#### Attributes

| Name | Description | Values |
| ---- | ----------- | ------ |
| string_attr | Attribute with any string value. | Any Str |
| state | Integer attribute with overridden name. | Any Int |
| enum_attr | Attribute with a known set of string values. | Str: ``red``, ``green``, ``blue`` |
| slice_attr | Attribute with a slice value. | Any Slice |
| map_attr | Attribute with a map value. | Any Map |

## Optional Metrics

The following metrics are not emitted by default. Each of them can be enabled by applying the following configuration:
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ all_set:
enabled: true
default.metric.to_be_removed:
enabled: true
metric.input_type:
enabled: true
optional.metric:
enabled: true
optional.metric.empty_unit:
Expand Down Expand Up @@ -32,6 +34,8 @@ none_set:
enabled: false
default.metric.to_be_removed:
enabled: false
metric.input_type:
enabled: false
optional.metric:
enabled: false
optional.metric.empty_unit:
Expand Down
11 changes: 11 additions & 0 deletions cmd/mdatagen/internal/samplereceiver/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,14 @@ metrics:
aggregation_temporality: delta
warnings:
if_enabled: This metric is deprecated and will be removed soon.

metric.input_type:
enabled: true
description: Monotonic cumulative sum int metric with string input_type enabled by default.
unit: s
sum:
value_type: int
input_type: string
monotonic: true
aggregation_temporality: cumulative
attributes: [ string_attr, overridden_int_attr, enum_attr, slice_attr, map_attr ]
12 changes: 12 additions & 0 deletions cmd/mdatagen/loader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,18 @@ func TestLoadMetadata(t *testing.T) {
Mono: Mono{Monotonic: false},
},
},
"metric.input_type": {
Enabled: true,
Description: "Monotonic cumulative sum int metric with string input_type enabled by default.",
Unit: strPtr("s"),
Sum: &sum{
MetricValueType: MetricValueType{pmetric.NumberDataPointValueTypeInt},
MetricInputType: MetricInputType{InputType: "string"},
AggregationTemporality: AggregationTemporality{Aggregation: pmetric.AggregationTemporalityCumulative},
Mono: Mono{Monotonic: true},
},
Attributes: []attributeName{"string_attr", "overridden_int_attr", "enum_attr", "slice_attr", "map_attr"},
},
},
ScopeName: "go.opentelemetry.io/collector/internal/receiver/samplereceiver",
ShortFolderName: "sample",
Expand Down
2 changes: 1 addition & 1 deletion component/telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
// TelemetrySettings provides components with APIs to report telemetry.
//
// Note: there is a service version of this struct, servicetelemetry.TelemetrySettings, that mirrors
// this struct with the exception of ReportComponentStatus. When adding or removing anything from
// this struct with the exception of ReportStatus. When adding or removing anything from
// this struct consider whether or not the same should be done for the service version.
type TelemetrySettings struct {
// Logger that the factory can use during creation and can pass to the created
Expand Down
1 change: 1 addition & 0 deletions config/configgrpc/configgrpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ type ServerConfig struct {
}

// SanitizedEndpoint strips the prefix of either http:// or https:// from configgrpc.ClientConfig.Endpoint.
// Deprecated: [v0.97.0]
func (gcs *ClientConfig) SanitizedEndpoint() string {
switch {
case gcs.isSchemeHTTP():
Expand Down
14 changes: 13 additions & 1 deletion exporter/otlpexporter/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package otlpexporter // import "go.opentelemetry.io/collector/exporter/otlpexpor

import (
"errors"
"strings"

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/config/configgrpc"
Expand All @@ -22,10 +23,21 @@ type Config struct {
}

func (c *Config) Validate() error {
if c.SanitizedEndpoint() == "" {
if c.sanitizedEndpoint() == "" {
return errors.New(`requires a non-empty "endpoint"`)
}
return nil
}

func (c *Config) sanitizedEndpoint() string {
switch {
case strings.HasPrefix(c.Endpoint, "http://"):
return strings.TrimPrefix(c.Endpoint, "http://")
case strings.HasPrefix(c.Endpoint, "https://"):
return strings.TrimPrefix(c.Endpoint, "https://")
default:
return c.Endpoint
}
}

var _ component.Config = (*Config)(nil)
4 changes: 4 additions & 0 deletions exporter/otlpexporter/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ func TestUnmarshalInvalidConfig(t *testing.T) {
name: "no_endpoint",
errorMsg: `requires a non-empty "endpoint"`,
},
{
name: "https_endpoint",
errorMsg: `requires a non-empty "endpoint"`,
},
{
name: "http_endpoint",
errorMsg: `requires a non-empty "endpoint"`,
Expand Down
2 changes: 2 additions & 0 deletions exporter/otlpexporter/testdata/invalid_configs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ no_endpoint:
multiplier: 1.3
max_interval: 60s
max_elapsed_time: 10m
https_endpoint:
endpoint: https://
http_endpoint:
endpoint: http://
timeout: 10s
Expand Down

0 comments on commit 181c632

Please sign in to comment.