-
Notifications
You must be signed in to change notification settings - Fork 10
/
otel.go
58 lines (49 loc) · 1.3 KB
/
otel.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package fhevm
import (
"math/big"
"github.com/zama-ai/fhevm-go/fhevm/tfhe"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/trace"
)
const operandTypeAttrName = "operand_types"
// The operand interface is used to get the string
// representation of any operand that comes in,either
// it's encrypted or not
type operand interface {
typeName() string
}
type plainOperand big.Int
type encryptedOperand verifiedCiphertext
func (plainOperand) typeName() string {
return "plainScalar"
}
func (op encryptedOperand) typeName() string {
ct := verifiedCiphertext(op)
return ct.fheUintType().String()
}
func otelDescribeOperands(span trace.Span, operands ...operand) {
if span == nil {
return
}
var operandTypes string
for i, ot := range operands {
operandTypes += ot.typeName()
if i < len(operands)-1 {
operandTypes += ","
}
}
span.SetAttributes(attribute.KeyValue{Key: operandTypeAttrName, Value: attribute.StringValue(operandTypes)})
}
func otelDescribeOperandsFheTypes(span trace.Span, types ...tfhe.FheUintType) {
if span == nil {
return
}
var operandTypes string
for i, t := range types {
operandTypes += t.String()
if i < len(types)-1 {
operandTypes += ","
}
}
span.SetAttributes(attribute.KeyValue{Key: operandTypeAttrName, Value: attribute.StringValue(operandTypes)})
}