Skip to content

Commit

Permalink
Merge branch 'main' into embedded_struct_unmarshaler
Browse files Browse the repository at this point in the history
  • Loading branch information
atoulme committed Mar 22, 2024
2 parents 245938d + 2037527 commit 429f386
Show file tree
Hide file tree
Showing 13 changed files with 452 additions and 74 deletions.
25 changes: 25 additions & 0 deletions .chloggen/configgrpc-remove-deprecated-func.yaml
@@ -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: breaking

# 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: Remove deprecated `ToServer` function.

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

# (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: [api]
25 changes: 25 additions & 0 deletions .chloggen/configgrpc-remove-deprecated-func2.yaml
@@ -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: Deprecated `ToServerContext`, use `ToServer` instead.

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

# (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: [api]
25 changes: 25 additions & 0 deletions .chloggen/confignet-add-newdefault-func.yaml
@@ -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: enhancement

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

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Adds `NewDefault*` functions for all the config structs.

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

# (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: [api]
25 changes: 25 additions & 0 deletions .chloggen/fix_empty_response.yaml
@@ -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: bug_fix

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

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: prevent error on empty response body when content type is application/json

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

# (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: [user]
17 changes: 13 additions & 4 deletions .github/workflows/build-and-test.yml
Expand Up @@ -137,10 +137,18 @@ jobs:
unittest-matrix:
strategy:
matrix:
runner: [ubuntu-latest, actuated-arm64-4cpu-4gb]
go-version: ["~1.22", "~1.21.8"] # 1.20 needs quotes otherwise it's interpreted as 1.2
runs-on: ubuntu-latest
runs-on: ${{ matrix.runner }}
needs: [setup-environment]
steps:
- name: Set up arkade
uses: alexellis/setup-arkade@v3
- name: Install vmmeter
run: |
sudo -E arkade oci install ghcr.io/openfaasltd/vmmeter:latest --path /usr/local/bin/
- name: Run vmmeter
uses: self-actuated/vmmeter-action@v1
- name: Checkout Repo
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Setup Go
Expand All @@ -155,14 +163,15 @@ jobs:
path: |
~/go/bin
~/go/pkg/mod
key: go-cache-${{ runner.os }}-${{ hashFiles('**/go.sum') }}
key: go-cache-${{ runner.os }}-${{ matrix.runner }}-${{ hashFiles('**/go.sum') }}
- name: Cache Build
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
path: ~/.cache/go-build
key: unittest-${{ runner.os }}-go-build-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
key: unittest-${{ runner.os }}-${{ matrix.runner }}-go-build-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
- name: Run Unit Tests
run: make gotest
run: |
make -j4 gotest
unittest:
if: always()
runs-on: ubuntu-latest
Expand Down
14 changes: 7 additions & 7 deletions config/configgrpc/configgrpc.go
Expand Up @@ -269,13 +269,7 @@ func validateBalancerName(balancerName string) bool {
}

// ToServer returns a grpc.Server for the configuration
// Deprecated: [0.96.0] Use ToServerContext instead.
func (gss *ServerConfig) ToServer(host component.Host, settings component.TelemetrySettings, extraOpts ...grpc.ServerOption) (*grpc.Server, error) {
return gss.ToServerContext(context.Background(), host, settings, extraOpts...)
}

// ToServerContext returns a grpc.Server for the configuration
func (gss *ServerConfig) ToServerContext(_ context.Context, host component.Host, settings component.TelemetrySettings, extraOpts ...grpc.ServerOption) (*grpc.Server, error) {
func (gss *ServerConfig) ToServer(_ context.Context, host component.Host, settings component.TelemetrySettings, extraOpts ...grpc.ServerOption) (*grpc.Server, error) {
opts, err := gss.toServerOption(host, settings)
if err != nil {
return nil, err
Expand All @@ -284,6 +278,12 @@ func (gss *ServerConfig) ToServerContext(_ context.Context, host component.Host,
return grpc.NewServer(opts...), nil
}

// ToServerContext returns a grpc.Server for the configuration
// Deprecated: [v0.97.0] Use ToServer instead.
func (gss *ServerConfig) ToServerContext(ctx context.Context, host component.Host, settings component.TelemetrySettings, extraOpts ...grpc.ServerOption) (*grpc.Server, error) {
return gss.ToServer(ctx, host, settings, extraOpts...)
}

func (gss *ServerConfig) toServerOption(host component.Host, settings component.TelemetrySettings) ([]grpc.ServerOption, error) {
switch gss.NetAddr.Transport {
case confignet.TransportTypeTCP, confignet.TransportTypeTCP4, confignet.TransportTypeTCP6, confignet.TransportTypeUDP, confignet.TransportTypeUDP4, confignet.TransportTypeUDP6:
Expand Down
2 changes: 1 addition & 1 deletion config/configgrpc/configgrpc_test.go
Expand Up @@ -256,7 +256,7 @@ func TestGrpcServerAuthSettings_Deprecated(t *testing.T) {
mockID: auth.NewServer(),
},
}
srv, err := gss.ToServer(host, componenttest.NewNopTelemetrySettings())
srv, err := gss.ToServer(context.Background(), host, componenttest.NewNopTelemetrySettings())
assert.NoError(t, err)
assert.NotNil(t, srv)
}
Expand Down
19 changes: 19 additions & 0 deletions config/confignet/confignet.go
Expand Up @@ -62,6 +62,11 @@ type DialerConfig struct {
Timeout time.Duration `mapstructure:"timeout"`
}

// NewDefaultDialerConfig creates a new DialerConfig with any default values set
func NewDefaultDialerConfig() DialerConfig {
return DialerConfig{}
}

// AddrConfig represents a network endpoint address.
type AddrConfig struct {
// Endpoint configures the address for this network connection.
Expand All @@ -79,6 +84,13 @@ type AddrConfig struct {
DialerConfig DialerConfig `mapstructure:"dialer"`
}

// NewDefaultAddrConfig creates a new AddrConfig with any default values set
func NewDefaultAddrConfig() AddrConfig {
return AddrConfig{
DialerConfig: NewDefaultDialerConfig(),
}
}

// Dial equivalent with net.Dialer's DialContext for this address.
func (na *AddrConfig) Dial(ctx context.Context) (net.Conn, error) {
d := net.Dialer{Timeout: na.DialerConfig.Timeout}
Expand Down Expand Up @@ -124,6 +136,13 @@ type TCPAddrConfig struct {
DialerConfig DialerConfig `mapstructure:"dialer"`
}

// NewDefaultTCPAddrConfig creates a new TCPAddrConfig with any default values set
func NewDefaultTCPAddrConfig() TCPAddrConfig {
return TCPAddrConfig{
DialerConfig: NewDefaultDialerConfig(),
}
}

// Dial equivalent with net.Dialer's DialContext for this address.
func (na *TCPAddrConfig) Dial(ctx context.Context) (net.Conn, error) {
d := net.Dialer{Timeout: na.DialerConfig.Timeout}
Expand Down
18 changes: 18 additions & 0 deletions config/confignet/confignet_test.go
Expand Up @@ -14,6 +14,24 @@ import (
"github.com/stretchr/testify/require"
)

func TestNewDefaultDialerConfig(t *testing.T) {
expectedDialerConfig := DialerConfig{}
dialerConfig := NewDefaultDialerConfig()
require.Equal(t, expectedDialerConfig, dialerConfig)
}

func TestNewDefaultAddrConfig(t *testing.T) {
expectedAddrConfig := AddrConfig{}
addrConfig := NewDefaultAddrConfig()
require.Equal(t, expectedAddrConfig, addrConfig)
}

func TestNewDefaultTCPAddrConfig(t *testing.T) {
expectedTCPAddrConfig := TCPAddrConfig{}
tcpAddrconfig := NewDefaultTCPAddrConfig()
require.Equal(t, expectedTCPAddrConfig, tcpAddrconfig)
}

func TestAddrConfigTimeout(t *testing.T) {
nac := &AddrConfig{
Endpoint: "localhost:0",
Expand Down
9 changes: 9 additions & 0 deletions exporter/otlphttpexporter/otlp.go
Expand Up @@ -301,6 +301,9 @@ func handlePartialSuccessResponse(resp *http.Response, partialSuccessHandler par
type partialSuccessHandler func(bytes []byte, contentType string) error

func (e *baseExporter) tracesPartialSuccessHandler(protoBytes []byte, contentType string) error {
if protoBytes == nil {
return nil
}
exportResponse := ptraceotlp.NewExportResponse()
switch contentType {
case protobufContentType:
Expand Down Expand Up @@ -328,6 +331,9 @@ func (e *baseExporter) tracesPartialSuccessHandler(protoBytes []byte, contentTyp
}

func (e *baseExporter) metricsPartialSuccessHandler(protoBytes []byte, contentType string) error {
if protoBytes == nil {
return nil
}
exportResponse := pmetricotlp.NewExportResponse()
switch contentType {
case protobufContentType:
Expand Down Expand Up @@ -355,6 +361,9 @@ func (e *baseExporter) metricsPartialSuccessHandler(protoBytes []byte, contentTy
}

func (e *baseExporter) logsPartialSuccessHandler(protoBytes []byte, contentType string) error {
if protoBytes == nil {
return nil
}
exportResponse := plogotlp.NewExportResponse()
switch contentType {
case protobufContentType:
Expand Down

0 comments on commit 429f386

Please sign in to comment.