Skip to content
Merged
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: 0 additions & 8 deletions logging/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ type Logger interface {
Metrics(category telemetryspec.Category, metrics telemetryspec.MetricDetails, details interface{})
Event(category telemetryspec.Category, identifier telemetryspec.Event)
EventWithDetails(category telemetryspec.Category, identifier telemetryspec.Event, details interface{})
StartOperation(category telemetryspec.Category, identifier telemetryspec.Operation) TelemetryOperation
GetTelemetrySession() string
GetTelemetryGUID() string
GetInstanceName() string
Expand Down Expand Up @@ -458,13 +457,6 @@ func (l logger) EventWithDetails(category telemetryspec.Category, identifier tel
}
}

func (l logger) StartOperation(category telemetryspec.Category, identifier telemetryspec.Operation) TelemetryOperation {
if l.loggerState.telemetry != nil {
return l.loggerState.telemetry.logStartOperation(l, category, identifier)
}
return TelemetryOperation{}
}

func (l logger) CloseTelemetry() {
if l.loggerState.telemetry != nil {
l.loggerState.telemetry.Close()
Expand Down
6 changes: 0 additions & 6 deletions logging/telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,12 +244,6 @@ func (t *telemetryState) logEvent(l logger, category telemetryspec.Category, ide
t.logTelemetry(l, buildMessage(string(category), string(identifier)), details)
}

func (t *telemetryState) logStartOperation(l logger, category telemetryspec.Category, identifier telemetryspec.Operation) TelemetryOperation {
op := makeTelemetryOperation(t, category, identifier)
t.logTelemetry(l, buildMessage(string(category), string(identifier), "Start"), nil)
return op
}

func buildMessage(args ...string) string {
message := telemetryPrefix + strings.Join(args, telemetrySeparator)
return message
Expand Down
15 changes: 1 addition & 14 deletions logging/telemetryCommon.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,11 @@
package logging

import (
"sync"
"time"

"github.com/algorand/go-deadlock"
"github.com/sirupsen/logrus"

"github.com/algorand/go-algorand/logging/telemetryspec"
"sync"
)

// TelemetryOperation wraps the context for an ongoing telemetry.StartOperation call
type TelemetryOperation struct {
startTime time.Time
category telemetryspec.Category
identifier telemetryspec.Operation
telemetryState *telemetryState
pending int32
}

type telemetryHook interface {
Fire(entry *logrus.Entry) error
Levels() []logrus.Level
Expand Down
51 changes: 0 additions & 51 deletions logging/telemetryOperation.go

This file was deleted.

31 changes: 3 additions & 28 deletions logging/telemetry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,10 @@ package logging
import (
"encoding/json"
"fmt"
"os"
"testing"
"time"

"github.com/sirupsen/logrus"
"github.com/stretchr/testify/require"
"os"
"testing"

"github.com/algorand/go-deadlock"

Expand Down Expand Up @@ -159,17 +157,11 @@ func TestTelemetryHook(t *testing.T) {

f.telem.logMetrics(f.l, testString1, testMetrics{}, nil)
f.telem.logEvent(f.l, testString1, testString2, nil)
op := f.telem.logStartOperation(f.l, testString1, testString2)
time.Sleep(1 * time.Millisecond)
op.Stop(f.l, nil)

entries := f.hookEntries()
a.Equal(4, len(entries))
a.Equal(2, len(entries))
a.Equal(buildMessage(testString1, testString2), entries[0])
a.Equal(buildMessage(testString1, testString2), entries[1])
a.Equal(buildMessage(testString1, testString2, "Start"), entries[2])
a.Equal(buildMessage(testString1, testString2, "Stop"), entries[3])
a.NotZero(f.hookData()[3]["duration"])
}

func TestNilMetrics(t *testing.T) {
Expand All @@ -182,23 +174,6 @@ func TestNilMetrics(t *testing.T) {
a.Zero(len(f.hookEntries()))
}

func TestMultipleOperationStop(t *testing.T) {
partitiontest.PartitionTest(t)
a := require.New(t)
f := makeTelemetryTestFixture(logrus.InfoLevel)

op := f.telem.logStartOperation(f.l, testString1, testString2)
op.Stop(f.l, nil)

// Start and stop should result in 2 entries
a.Equal(2, len(f.hookEntries()))

op.Stop(f.l, nil)

// Calling stop again should not result in another entry
a.Equal(2, len(f.hookEntries()))
}

func TestDetails(t *testing.T) {
partitiontest.PartitionTest(t)
a := require.New(t)
Expand Down
23 changes: 0 additions & 23 deletions logging/telemetryspec/operation.go

This file was deleted.