Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions collector/internal/telemetryapi/listener_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,6 @@ func setupListener(t *testing.T) (*Listener, string) {

address, err := listener.Start()
require.NoError(t, err)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The use of t.Cleanup() appeared to trigger a race condition using the race detector with zap.Logger switching to using defer appears to fix the issue.

t.Cleanup(func() {
listener.Shutdown()
})

return listener, address
}

Expand Down Expand Up @@ -183,6 +178,7 @@ func TestListenOnAddress(t *testing.T) {

func TestListener_StartAndShutdown(t *testing.T) {
listener, address := setupListener(t)
defer listener.Shutdown()
require.NotEqual(t, address, "", "Start() should not return an empty address")
require.True(t, strings.HasPrefix(address, "http://"), "Address should start with http://")
require.NotNil(t, listener.httpServer, "httpServer should not be nil")
Expand Down Expand Up @@ -241,6 +237,7 @@ func TestListener_httpHandler(t *testing.T) {
for _, test := range testCases {
t.Run(test.name, func(t *testing.T) {
listener, address := setupListener(t)
defer listener.Shutdown()
submitEvents(t, address, test.events)
require.EventuallyWithT(t, func(c *assert.CollectT) {
require.Equal(c, test.expectedCount, listener.queue.Len())
Expand Down Expand Up @@ -302,6 +299,7 @@ func TestListener_Wait_Success(t *testing.T) {
for _, test := range testCases {
t.Run(test.name, func(t *testing.T) {
listener, address := setupListener(t)
defer listener.Shutdown()

waitDone := make(chan error, 1)
go func() {
Expand Down
24 changes: 19 additions & 5 deletions collector/internal/telemetryapi/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,29 @@ const (
PlatformInitStart EventType = Platform + ".initStart"
// PlatformInitRuntimeDone is used when function initialization ended.
PlatformInitRuntimeDone EventType = Platform + ".initRuntimeDone"
// PlatformReport is used when a report of function invocation is received.
PlatformReport EventType = Platform + ".report"
// Function invocation started.
// PlatformInitReport is used when a report of function initialization is received.
PlatformInitReport EventType = Platform + ".initReport"
// PlatformStart is used when function invocation started.
PlatformStart EventType = Platform + ".start"
// The runtime finished processing an event with either success or failure.
// PlatformRuntimeDone is used when the runtime finished processing an event with either success or failure.
PlatformRuntimeDone EventType = Platform + ".runtimeDone"
// PlatformReport is used when a report of function invocation is received.
PlatformReport EventType = Platform + ".report"
// PlatformRestoreStart is used when runtime restore started.
PlatformRestoreStart EventType = Platform + ".restoreStart"
// PlatformRestoreRuntimeDone is used when runtime restore completed.
PlatformRestoreRuntimeDone EventType = Platform + ".restoreRuntimeDone"
// PlatformRestoreReport is used when a report of runtime restore is received.
PlatformRestoreReport EventType = Platform + ".restoreReport"
// PlatformExtension is used for extension state events.
PlatformExtension EventType = Platform + ".extension"
// PlatformTelemetrySubscription is used when the extension subscribed to the Telemetry API.
PlatformTelemetrySubscription EventType = Platform + ".telemetrySubscription"
// PlatformLogsDropped is used when Lambda dropped log entries.
PlatformLogsDropped EventType = Platform + ".logsDropped"
// Function is used to receive log events emitted by the function
Function EventType = "function"
// Extension is used is to receive log events emitted by the extension
// Extension is used to receive log events emitted by the extension
Extension EventType = "extension"
)

Expand Down
3 changes: 2 additions & 1 deletion collector/lambdacomponents/receiver/telemetryapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
package receiver

import (
"github.com/open-telemetry/opentelemetry-lambda/collector/receiver/telemetryapireceiver"
"go.opentelemetry.io/collector/receiver"

"github.com/open-telemetry/opentelemetry-lambda/collector/receiver/telemetryapireceiver"
)

func init() {
Expand Down
2 changes: 1 addition & 1 deletion collector/receiver/telemetryapireceiver/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type Config struct {
extensionID string
Port int `mapstructure:"port"`
Types []string `mapstructure:"types"`
LogReport bool `mapstructure:"log_report"`
LogReport *bool `mapstructure:"log_report"`
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Switch to pointer to allow default value to be true

}

// Validate validates the configuration by checking for missing or invalid fields
Expand Down
Loading
Loading