Skip to content

Commit 38d4d54

Browse files
committed
remove Report method
1 parent 4527daa commit 38d4d54

File tree

5 files changed

+15
-32
lines changed

5 files changed

+15
-32
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Learn more on the [features](https://stackimpact.com/features/) page (with scree
2020

2121
#### How it works
2222

23-
The StackImpact profiler agent is imported into a program and used as a normal package. When the program runs, various sampling profilers are started and stopped automatically by the agent and/or programmatically using the agent methods. The agent periodically reports recorded profiles and metrics to the StackImpact Dashboard. If an application has multiple processes, also referred to as workers, instances or nodes, only one process will have an active agent at any point of time. The agent can also operate in manual mode, which should be used in development only.
23+
The StackImpact profiler agent is imported into a program and used as a normal package. When the program runs, various sampling profilers are started and stopped automatically by the agent and/or programmatically using the agent methods. The agent periodically reports recorded profiles and metrics to the StackImpact Dashboard. The agent can also operate in manual mode, which should be used in development only.
2424

2525

2626
#### Documentation
@@ -218,4 +218,4 @@ To enable debug logging, add `Debug: true` to startup options. If the debug log
218218

219219
## Overhead
220220

221-
The agent overhead is measured to be less than 1% for applications under high load. For applications that are horizontally scaled to multiple processes, StackImpact agents are only active on a small subset of the processes at any point of time, therefore the total overhead is much lower.
221+
The agent overhead is measured to be less than 1% for applications under high load.

agent.go

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"fmt"
55
"log"
66
"net/http"
7-
"sync/atomic"
87

98
"github.com/stackimpact/stackimpact-go/internal"
109
)
@@ -31,8 +30,7 @@ type Options struct {
3130
type Agent struct {
3231
internalAgent *internal.Agent
3332

34-
spanStarted int32
35-
reportStarted int32
33+
spanStarted int32
3634

3735
// compatibility < 1.2.0
3836
DashboardAddress string
@@ -47,7 +45,6 @@ func NewAgent() *Agent {
4745
a := &Agent{
4846
internalAgent: internal.NewAgent(),
4947
spanStarted: 0,
50-
reportStarted: 0,
5148
}
5249

5350
return a
@@ -284,24 +281,10 @@ func (a *Agent) RecordAndRecoverPanic() {
284281
}
285282
}
286283

287-
// Reports profiles to the Dashboard in manual or focused profiling mode.
288-
// Only reports once every few minutes and only if the agent is active.
284+
// DEPRECATED. Kept for compatibility.
289285
func (a *Agent) Report() {
290-
a.ReportWithHTTPClient(nil)
291286
}
292287

293-
// Same as Report, but uses given http.Client.
288+
// DEPRECATED. Kept for compatibility.
294289
func (a *Agent) ReportWithHTTPClient(client *http.Client) {
295-
if !atomic.CompareAndSwapInt32(&a.reportStarted, 0, 1) {
296-
return
297-
}
298-
defer func() {
299-
atomic.StoreInt32(&a.reportStarted, 0)
300-
}()
301-
302-
if client != nil {
303-
a.internalAgent.HTTPClient = client
304-
}
305-
306-
a.internalAgent.Report()
307290
}

examples/aws-lambda/main.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@ func Handler(request events.APIGatewayProxyRequest) (events.APIGatewayProxyRespo
1818
span := agent.Profile()
1919
defer span.Stop()
2020

21-
// periodically send profiles to the sashboard (not on every request)
22-
defer agent.Report()
23-
2421
// simulate cpu work
2522
for i := 0; i < 1000000; i++ {
2623
rand.Intn(1000)

internal/agent.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616
"time"
1717
)
1818

19-
const AgentVersion = "2.3.9"
19+
const AgentVersion = "2.3.10"
2020
const SAASDashboardAddress = "https://agent-api.stackimpact.com"
2121

2222
var agentPath = filepath.Join("github.com", "stackimpact", "stackimpact-go")
@@ -305,13 +305,11 @@ func (a *Agent) Report() {
305305

306306
a.configLoader.load()
307307

308-
if !a.AutoProfiling {
309-
a.cpuReporter.report(true)
310-
a.allocationReporter.report(true)
311-
a.blockReporter.report(true)
308+
a.cpuReporter.report(true)
309+
a.allocationReporter.report(true)
310+
a.blockReporter.report(true)
312311

313-
a.messageQueue.flush(true)
314-
}
312+
a.messageQueue.flush(true)
315313
}
316314

317315
func (a *Agent) log(format string, values ...interface{}) {

span.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ func (s *Span) Stop() {
4242
if s.active {
4343
s.agent.internalAgent.StopProfiling()
4444
}
45+
46+
if !s.agent.internalAgent.AutoProfiling {
47+
s.agent.internalAgent.Report()
48+
}
49+
4550
atomic.StoreInt32(&s.agent.spanStarted, 0)
4651
}
4752
}

0 commit comments

Comments
 (0)