Skip to content

Commit

Permalink
review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
nithinputhenveettil committed Sep 3, 2024
1 parent 0db254d commit 6519b93
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ Another interesting feature is the usage of additional packages located under [i
1. [Tracing an application running on Azure Container Apps](docs/azure_container_apps.md)
1. [Tracing Other Go Packages](docs/other_packages.md)
1. [Instrumenting Code Manually](docs/manual_instrumentation.md)
1. [Generic Serverless Agent](/docs/generic_serverless.md)
1. [Generic Serverless Agent](/docs/generic_serverless_agent.md)

<!-- Links section -->

Expand Down
File renamed without changes.
19 changes: 11 additions & 8 deletions generic_serverless_agent.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// (c) Copyright IBM Corp. 2022
// (c) Copyright IBM Corp. 2024

package instana

Expand Down Expand Up @@ -44,19 +44,25 @@ func newGenericServerlessAgent(acceptorEndpoint, agentKey string, client *http.C

if client == nil {
client = http.DefaultClient
// TODO: defaultServerlessTimeout is increased from 500 millisecond to 2 second
// as serverless API latency is high. This should be reduced once latency is minimized.
// You can change this timeout by setting the INSTANA_TIMEOUT environment variable.
client.Timeout = 2 * time.Second
}

logger.Debug("initializing local serverless agent")
logger.Debug("initializing generic serverless agent")

// Creating a unique serverless host ID.
uniqHostId := "Generic_Serverless_Agent" + uuid.New().String()

agent := &genericServerlessAgent{
Endpoint: acceptorEndpoint,
Key: agentKey,
PID: os.Getpid(),
client: client,
logger: logger,
snapshot: serverlessSnapshot{
Host: uniqHostId,
EntityID: uniqHostId,
},
}

go func() {
Expand Down Expand Up @@ -87,10 +93,7 @@ func (a *genericServerlessAgent) SendSpans(spans []Span) error {
func (a *genericServerlessAgent) SendProfiles([]autoprofile.Profile) error { return nil }

func (a *genericServerlessAgent) Flush(ctx context.Context) error {
// Since we currently don't send metrics in the generic_serverless setup and infrastructure correlation isn't possible,
// these values can be anything. We just need to ensure there's no conflict with the existing infrastructure tags.
// This will need to change if we add metrics and infrastructure correlation in the future.
from := newServerlessAgentFromS("Generic_Serverless_Agent"+uuid.New().String(), "generic_serverless")
from := newServerlessAgentFromS(a.snapshot.EntityID, "generic_serverless")

payload := struct {
Spans []Span `json:"spans,omitempty"`
Expand Down

0 comments on commit 6519b93

Please sign in to comment.