Skip to content
This repository has been archived by the owner on Aug 17, 2020. It is now read-only.

Concurrency support on recorder and config specification #176

Closed
wants to merge 6 commits into from

Conversation

tonyredondo
Copy link
Contributor

@tonyredondo tonyredondo commented Feb 24, 2020

Closes #173

This PR adds support for concurrency levels in the recorder, following the configuration specification, also adds some other missing keys from the configuration.

Examples:

  • Concurrency level: 1 , Time: 2min, 13sec
2020/02/24 11:52:40 agent.go:212: environment variable $SCOPE_DSN not found
2020/02/24 11:52:40 agent.go:220: API key found in the native app configuration
2020/02/24 11:52:40 agent.go:233: API endpoint found in the native app configuration
2020/02/24 11:52:40 recorder.go:88: recorder frequency: 1s
2020/02/24 11:52:40 recorder.go:89: recorder concurrency level: 1
2020/02/24 11:52:41 recorder.go:158: sending 4221 spans in 5 batches
2020/02/24 11:52:41 ntp.go:44: ntp offset: 5.699595ms
2020/02/24 11:52:41 recorder.go:217: sending batch 1/5 with 1000 spans
2020/02/24 11:52:45 agent.go:393: Scope agent is stopping gracefully...
2020/02/24 11:52:50 recorder.go:217: sending batch 2/5 with 1000 spans
2020/02/24 11:52:56 recorder.go:217: sending batch 3/5 with 1000 spans
2020/02/24 11:53:02 recorder.go:217: sending batch 4/5 with 1000 spans
2020/02/24 11:53:08 recorder.go:217: sending batch 5/5 with 221 spans
2020/02/24 11:53:10 recorder.go:158: sending 15880 spans in 16 batches
2020/02/24 11:53:10 recorder.go:217: sending batch 1/16 with 1000 spans
2020/02/24 11:53:17 recorder.go:217: sending batch 2/16 with 1000 spans
2020/02/24 11:53:23 recorder.go:217: sending batch 3/16 with 1000 spans
2020/02/24 11:53:30 recorder.go:217: sending batch 4/16 with 1000 spans
2020/02/24 11:53:37 recorder.go:217: sending batch 5/16 with 1000 spans
2020/02/24 11:53:43 recorder.go:217: sending batch 6/16 with 1000 spans
2020/02/24 11:53:48 recorder.go:217: sending batch 7/16 with 1000 spans
2020/02/24 11:53:53 recorder.go:217: sending batch 8/16 with 1000 spans
2020/02/24 11:53:59 recorder.go:217: sending batch 9/16 with 1000 spans
2020/02/24 11:54:07 recorder.go:217: sending batch 10/16 with 1000 spans
2020/02/24 11:54:13 recorder.go:217: sending batch 11/16 with 1000 spans
2020/02/24 11:54:20 recorder.go:217: sending batch 12/16 with 1000 spans
2020/02/24 11:54:26 recorder.go:217: sending batch 13/16 with 1000 spans
2020/02/24 11:54:32 recorder.go:217: sending batch 14/16 with 1000 spans
2020/02/24 11:54:38 recorder.go:217: sending batch 15/16 with 1000 spans
2020/02/24 11:54:44 recorder.go:217: sending batch 16/16 with 880 spans
2020/02/24 11:54:53 recorder.go:158: sending 0 spans in 1 batches
  • Concurrency level: 5 , Time: 55sec
2020/02/24 11:49:00 agent.go:212: environment variable $SCOPE_DSN not found
2020/02/24 11:49:00 agent.go:220: API key found in the native app configuration
2020/02/24 11:49:00 agent.go:233: API endpoint found in the native app configuration
2020/02/24 11:49:00 recorder.go:88: recorder frequency: 1s
2020/02/24 11:49:00 recorder.go:89: recorder concurrency level: 5
2020/02/24 11:49:01 recorder.go:158: sending 4020 spans in 5 batches
2020/02/24 11:49:01 ntp.go:44: ntp offset: 4.941899ms
2020/02/24 11:49:01 recorder.go:217: sending batch 5/5 with 20 spans
2020/02/24 11:49:01 recorder.go:217: sending batch 1/5 with 1000 spans
2020/02/24 11:49:01 recorder.go:217: sending batch 2/5 with 1000 spans
2020/02/24 11:49:01 recorder.go:217: sending batch 3/5 with 1000 spans
2020/02/24 11:49:01 recorder.go:217: sending batch 4/5 with 1000 spans
2020/02/24 11:49:05 agent.go:393: Scope agent is stopping gracefully...
2020/02/24 11:49:12 recorder.go:158: sending 16081 spans in 17 batches
2020/02/24 11:49:13 recorder.go:217: sending batch 1/17 with 1000 spans
2020/02/24 11:49:13 recorder.go:217: sending batch 3/17 with 1000 spans
2020/02/24 11:49:13 recorder.go:217: sending batch 4/17 with 1000 spans
2020/02/24 11:49:13 recorder.go:217: sending batch 5/17 with 1000 spans
2020/02/24 11:49:13 recorder.go:217: sending batch 2/17 with 1000 spans
2020/02/24 11:49:25 recorder.go:217: sending batch 6/17 with 1000 spans
2020/02/24 11:49:26 recorder.go:217: sending batch 8/17 with 1000 spans
2020/02/24 11:49:26 recorder.go:217: sending batch 7/17 with 1000 spans
2020/02/24 11:49:26 recorder.go:217: sending batch 9/17 with 1000 spans
2020/02/24 11:49:27 recorder.go:217: sending batch 10/17 with 1000 spans
2020/02/24 11:49:35 recorder.go:217: sending batch 11/17 with 1000 spans
2020/02/24 11:49:37 recorder.go:217: sending batch 12/17 with 1000 spans
2020/02/24 11:49:38 recorder.go:217: sending batch 13/17 with 1000 spans
2020/02/24 11:49:38 recorder.go:217: sending batch 14/17 with 1000 spans
2020/02/24 11:49:38 recorder.go:217: sending batch 15/17 with 1000 spans
2020/02/24 11:49:46 recorder.go:217: sending batch 16/17 with 1000 spans
2020/02/24 11:49:47 recorder.go:217: sending batch 17/17 with 81 spans
2020/02/24 11:49:55 recorder.go:158: sending 0 spans in 1 batches
2020/02/24 11:49:55 recorder.go:158: sending 0 spans in 1 batches
  • Concurrency level: 20 , Time: 40sec
2020/02/24 12:06:30 agent.go:212: environment variable $SCOPE_DSN not found
2020/02/24 12:06:30 agent.go:220: API key found in the native app configuration
2020/02/24 12:06:30 agent.go:233: API endpoint found in the native app configuration
2020/02/24 12:06:30 recorder.go:88: recorder frequency: 1s
2020/02/24 12:06:30 recorder.go:89: recorder concurrency level: 20
2020/02/24 12:06:31 recorder.go:158: sending 4020 spans in 5 batches
2020/02/24 12:06:31 ntp.go:44: ntp offset: 955.156µs
2020/02/24 12:06:31 recorder.go:217: sending batch 5/5 with 20 spans
2020/02/24 12:06:32 recorder.go:217: sending batch 3/5 with 1000 spans
2020/02/24 12:06:32 recorder.go:217: sending batch 4/5 with 1000 spans
2020/02/24 12:06:32 recorder.go:217: sending batch 1/5 with 1000 spans
2020/02/24 12:06:32 recorder.go:217: sending batch 2/5 with 1000 spans
2020/02/24 12:06:35 agent.go:393: Scope agent is stopping gracefully...
2020/02/24 12:06:43 recorder.go:158: sending 16081 spans in 17 batches
2020/02/24 12:06:43 recorder.go:217: sending batch 17/17 with 81 spans
2020/02/24 12:06:44 recorder.go:217: sending batch 6/17 with 1000 spans
2020/02/24 12:06:44 recorder.go:217: sending batch 9/17 with 1000 spans
2020/02/24 12:06:44 recorder.go:217: sending batch 8/17 with 1000 spans
2020/02/24 12:06:44 recorder.go:217: sending batch 15/17 with 1000 spans
2020/02/24 12:06:44 recorder.go:217: sending batch 1/17 with 1000 spans
2020/02/24 12:06:44 recorder.go:217: sending batch 5/17 with 1000 spans
2020/02/24 12:06:44 recorder.go:217: sending batch 10/17 with 1000 spans
2020/02/24 12:06:44 recorder.go:217: sending batch 3/17 with 1000 spans
2020/02/24 12:06:44 recorder.go:217: sending batch 14/17 with 1000 spans
2020/02/24 12:06:44 recorder.go:217: sending batch 7/17 with 1000 spans
2020/02/24 12:06:44 recorder.go:217: sending batch 11/17 with 1000 spans
2020/02/24 12:06:44 recorder.go:217: sending batch 16/17 with 1000 spans
2020/02/24 12:06:44 recorder.go:217: sending batch 12/17 with 1000 spans
2020/02/24 12:06:44 recorder.go:217: sending batch 2/17 with 1000 spans
2020/02/24 12:06:44 recorder.go:217: sending batch 4/17 with 1000 spans
2020/02/24 12:06:44 recorder.go:217: sending batch 13/17 with 1000 spans
2020/02/24 12:07:10 recorder.go:158: sending 0 spans in 1 batches
2020/02/24 12:07:10 recorder.go:158: sending 0 spans in 1 batches

ScopeInstrumentationDbStatementValues = newBooleanEnvVar(false, "SCOPE_INSTRUMENTATION_DB_STATEMENT_VALUES")
ScopeTracerDispatcherHealthcheckFrequency = newIntEnvVar(60000, "SCOPE_TRACER_DISPATCHER_HEALTHCHECK_FRECUENCY")
ScopeTracerDispatcherHealthcheckFrequencyInTestMode = newIntEnvVar(1000, "SCOPE_TRACER_DISPATCHER_HEALTHCHECK_FRECUENCY_IN_TESTMODE")
ScopeTracerDispatcherConcurrencyLevel = newIntEnvVar(1, "SCOPE_TRACER_DISPATCHER_CONCURRENCY_LEVEL")
Copy link
Contributor

Choose a reason for hiding this comment

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

By default, we want "1" as concurrency level in Go?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

unless we decide new defaults for this setting? that is the default in .NET too

r.url = agent.getUrl("api/agent/ingest")
r.client = &http.Client{}
r.stats = &RecorderStats{}
r.s = semaphore.NewWeighted(int64(r.concurrencyLevel))
Copy link
Member

Choose a reason for hiding this comment

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

Why not use a fixed pool of go routines that read from a channel? Like https://gobyexample.com/worker-pools

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've found easier to implement (less code modification) with a semaphore... But yeah we can do it also with two channels... Do you prefer with a channel implementation?

@tonyredondo
Copy link
Contributor Author

This PR was superseed by #199

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Follow the standard configuration of the agents
3 participants