Documentation
¶
Index ¶
- Constants
- type AccountDurationAggregator
- type AccountManagerMetrics
- func (metrics *AccountManagerMetrics) CountGetPeerNetworkMapDuration(duration time.Duration)
- func (metrics *AccountManagerMetrics) CountNetworkMapObjects(count int64)
- func (metrics *AccountManagerMetrics) CountPeerMetUpdate()
- func (metrics *AccountManagerMetrics) CountPeerStatusUpdate(op PeerStatusOperation, outcome PeerStatusOutcome)
- func (metrics *AccountManagerMetrics) CountUpdateAccountPeersDuration(duration time.Duration)
- func (metrics *AccountManagerMetrics) CountUpdateAccountPeersTriggered(resource, operation string)
- func (metrics *AccountManagerMetrics) RecordPeerStatusUpdateDuration(op PeerStatusOperation, d time.Duration)
- type AppMetrics
- type EphemeralPeersMetrics
- func (m *EphemeralPeersMetrics) AddPending(n int64)
- func (m *EphemeralPeersMetrics) CountCleanupError()
- func (m *EphemeralPeersMetrics) CountCleanupRun()
- func (m *EphemeralPeersMetrics) CountPeersCleaned(n int64)
- func (m *EphemeralPeersMetrics) DecPending(n int64)
- func (m *EphemeralPeersMetrics) IncPending()
- type GRPCMetrics
- func (grpcMetrics *GRPCMetrics) CountGetKeyRequest()
- func (grpcMetrics *GRPCMetrics) CountLoginRequest()
- func (grpcMetrics *GRPCMetrics) CountLoginRequestBlocked()
- func (grpcMetrics *GRPCMetrics) CountLoginRequestDuration(duration time.Duration, accountID string)
- func (grpcMetrics *GRPCMetrics) CountSyncRequest()
- func (grpcMetrics *GRPCMetrics) CountSyncRequestBlocked()
- func (grpcMetrics *GRPCMetrics) CountSyncRequestDuration(duration time.Duration, accountID string)
- func (grpcMetrics *GRPCMetrics) RegisterConnectedStreams(producer func() int64) error
- func (metrics *GRPCMetrics) UpdateChannelQueueLength(length int)
- type HTTPMiddleware
- type IDPMetrics
- func (idpMetrics *IDPMetrics) CountAuthenticate()
- func (idpMetrics *IDPMetrics) CountCreateUser()
- func (idpMetrics *IDPMetrics) CountDeleteUser()
- func (idpMetrics *IDPMetrics) CountGetAccount()
- func (idpMetrics *IDPMetrics) CountGetAllAccounts()
- func (idpMetrics *IDPMetrics) CountGetUserByEmail()
- func (idpMetrics *IDPMetrics) CountGetUserDataByID()
- func (idpMetrics *IDPMetrics) CountRequestError()
- func (idpMetrics *IDPMetrics) CountRequestStatusError()
- func (idpMetrics *IDPMetrics) CountUpdateUserAppMetadata()
- type MockAppMetrics
- func (mock *MockAppMetrics) AccountManagerMetrics() *AccountManagerMetrics
- func (mock *MockAppMetrics) Close() error
- func (mock *MockAppMetrics) EphemeralPeersMetrics() *EphemeralPeersMetrics
- func (mock *MockAppMetrics) Expose(ctx context.Context, port int, endpoint string) error
- func (mock *MockAppMetrics) GRPCMetrics() *GRPCMetrics
- func (mock *MockAppMetrics) GetMeter() metric2.Meter
- func (mock *MockAppMetrics) HTTPMiddleware() *HTTPMiddleware
- func (mock *MockAppMetrics) IDPMetrics() *IDPMetrics
- func (mock *MockAppMetrics) StoreMetrics() *StoreMetrics
- func (mock *MockAppMetrics) UpdateChannelMetrics() *UpdateChannelMetrics
- type PeerStatusOperation
- type PeerStatusOutcome
- type StoreMetrics
- type UpdateChannelMetrics
- func (metrics *UpdateChannelMetrics) CountCalcPeerNetworkMapDuration(duration time.Duration)
- func (metrics *UpdateChannelMetrics) CountCalcPostureChecksDuration(duration time.Duration)
- func (metrics *UpdateChannelMetrics) CountCloseChannelDuration(duration time.Duration)
- func (metrics *UpdateChannelMetrics) CountCloseChannelsDuration(duration time.Duration, channels int)
- func (metrics *UpdateChannelMetrics) CountCreateChannelDuration(duration time.Duration, closed bool)
- func (metrics *UpdateChannelMetrics) CountGetAllConnectedPeersDuration(duration time.Duration, peers int)
- func (metrics *UpdateChannelMetrics) CountHasChannelDuration(duration time.Duration)
- func (metrics *UpdateChannelMetrics) CountMergeNetworkMapDuration(duration time.Duration)
- func (metrics *UpdateChannelMetrics) CountSendUpdateDuration(duration time.Duration, found, dropped bool)
- func (metrics *UpdateChannelMetrics) CountToSyncResponseDuration(duration time.Duration)
- type WrappedResponseWriter
Constants ¶
const ( PeerStatusConnect PeerStatusOperation = "connect" PeerStatusDisconnect PeerStatusOperation = "disconnect" // PeerStatusApplied — the fence WHERE matched and the UPDATE landed. PeerStatusApplied PeerStatusOutcome = "applied" // PeerStatusStale — the fence WHERE rejected the write because a // newer session has already taken ownership (connect: stored token // >= incoming; disconnect: stored token != incoming). PeerStatusStale PeerStatusOutcome = "stale" // PeerStatusError — the store returned a non-NotFound error. PeerStatusError PeerStatusOutcome = "error" // PeerStatusPeerNotFound — the peer lookup failed (the peer was // deleted between the gRPC sync handshake and the status write). PeerStatusPeerNotFound PeerStatusOutcome = "peer_not_found" )
const AccountIDLabel = "account_id"
const HighLatencyThreshold = time.Second * 7
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccountDurationAggregator ¶ added in v0.66.3
type AccountDurationAggregator struct {
FlushInterval time.Duration
MaxAge time.Duration
// contains filtered or unexported fields
}
AccountDurationAggregator uses OpenTelemetry histograms per account to calculate P95 without publishing individual account labels
func NewAccountDurationAggregator ¶ added in v0.66.3
func NewAccountDurationAggregator(ctx context.Context, flushInterval, maxAge time.Duration) *AccountDurationAggregator
NewAccountDurationAggregator creates aggregator using OTel histograms
func (*AccountDurationAggregator) FlushAndGetP95s ¶ added in v0.66.3
func (a *AccountDurationAggregator) FlushAndGetP95s() []int64
FlushAndGetP95s extracts P95 from each account's histogram
func (*AccountDurationAggregator) Record ¶ added in v0.66.3
func (a *AccountDurationAggregator) Record(accountID string, duration time.Duration)
Record adds a duration for an account using OTel histogram
func (*AccountDurationAggregator) Shutdown ¶ added in v0.66.3
func (a *AccountDurationAggregator) Shutdown() error
Shutdown cleans up resources
type AccountManagerMetrics ¶ added in v0.28.8
type AccountManagerMetrics struct {
// contains filtered or unexported fields
}
AccountManagerMetrics represents all metrics related to the AccountManager
func NewAccountManagerMetrics ¶ added in v0.28.8
func NewAccountManagerMetrics(ctx context.Context, meter metric.Meter) (*AccountManagerMetrics, error)
NewAccountManagerMetrics creates an instance of AccountManagerMetrics
func (*AccountManagerMetrics) CountGetPeerNetworkMapDuration ¶ added in v0.28.8
func (metrics *AccountManagerMetrics) CountGetPeerNetworkMapDuration(duration time.Duration)
CountGetPeerNetworkMapDuration counts the duration of getting the peer network map
func (*AccountManagerMetrics) CountNetworkMapObjects ¶ added in v0.28.8
func (metrics *AccountManagerMetrics) CountNetworkMapObjects(count int64)
CountNetworkMapObjects counts the number of network map objects
func (*AccountManagerMetrics) CountPeerMetUpdate ¶ added in v0.33.0
func (metrics *AccountManagerMetrics) CountPeerMetUpdate()
CountPeerMetUpdate counts the number of peer meta updates
func (*AccountManagerMetrics) CountPeerStatusUpdate ¶ added in v0.71.3
func (metrics *AccountManagerMetrics) CountPeerStatusUpdate(op PeerStatusOperation, outcome PeerStatusOutcome)
CountPeerStatusUpdate increments the connect/disconnect counter, labeled by operation and outcome. Both labels are bounded enums.
func (*AccountManagerMetrics) CountUpdateAccountPeersDuration ¶ added in v0.28.8
func (metrics *AccountManagerMetrics) CountUpdateAccountPeersDuration(duration time.Duration)
CountUpdateAccountPeersDuration counts the duration of updating account peers
func (*AccountManagerMetrics) CountUpdateAccountPeersTriggered ¶ added in v0.70.5
func (metrics *AccountManagerMetrics) CountUpdateAccountPeersTriggered(resource, operation string)
CountUpdateAccountPeersTriggered increments the counter for account peers updates with resource and operation labels.
func (*AccountManagerMetrics) RecordPeerStatusUpdateDuration ¶ added in v0.71.3
func (metrics *AccountManagerMetrics) RecordPeerStatusUpdateDuration(op PeerStatusOperation, d time.Duration)
RecordPeerStatusUpdateDuration records the wall-clock time spent running a peer status update (including post-write side effects), labeled by operation.
type AppMetrics ¶
type AppMetrics interface {
GetMeter() metric2.Meter
Close() error
Expose(ctx context.Context, port int, endpoint string) error
IDPMetrics() *IDPMetrics
HTTPMiddleware() *HTTPMiddleware
GRPCMetrics() *GRPCMetrics
StoreMetrics() *StoreMetrics
UpdateChannelMetrics() *UpdateChannelMetrics
AccountManagerMetrics() *AccountManagerMetrics
EphemeralPeersMetrics() *EphemeralPeersMetrics
}
AppMetrics is metrics interface
func NewAppMetricsWithMeter ¶ added in v0.65.0
NewAppMetricsWithMeter creates AppMetrics using an externally provided meter. The caller is responsible for exposing metrics via HTTP. Expose() and Close() are no-ops.
func NewDefaultAppMetrics ¶
func NewDefaultAppMetrics(ctx context.Context) (AppMetrics, error)
NewDefaultAppMetrics and expose them via defaultEndpoint on a given HTTP port
type EphemeralPeersMetrics ¶ added in v0.71.3
type EphemeralPeersMetrics struct {
// contains filtered or unexported fields
}
EphemeralPeersMetrics tracks the ephemeral peer cleanup pipeline: how many peers are currently scheduled for deletion, how many tick runs the cleaner has performed, how many peers it has removed, and how many delete batches failed.
func NewEphemeralPeersMetrics ¶ added in v0.71.3
func NewEphemeralPeersMetrics(ctx context.Context, meter metric.Meter) (*EphemeralPeersMetrics, error)
NewEphemeralPeersMetrics constructs the ephemeral cleanup counters.
func (*EphemeralPeersMetrics) AddPending ¶ added in v0.71.3
func (m *EphemeralPeersMetrics) AddPending(n int64)
AddPending bumps the pending gauge by n — used at startup when the initial set of ephemeral peers is loaded from the store.
func (*EphemeralPeersMetrics) CountCleanupError ¶ added in v0.71.3
func (m *EphemeralPeersMetrics) CountCleanupError()
CountCleanupError records a failed delete batch.
func (*EphemeralPeersMetrics) CountCleanupRun ¶ added in v0.71.3
func (m *EphemeralPeersMetrics) CountCleanupRun()
CountCleanupRun records one cleanup pass that processed >0 peers. Idle ticks (nothing to do) deliberately don't increment so the rate reflects useful work.
func (*EphemeralPeersMetrics) CountPeersCleaned ¶ added in v0.71.3
func (m *EphemeralPeersMetrics) CountPeersCleaned(n int64)
CountPeersCleaned records the number of peers a single tick deleted.
func (*EphemeralPeersMetrics) DecPending ¶ added in v0.71.3
func (m *EphemeralPeersMetrics) DecPending(n int64)
DecPending decreases the pending gauge — used both when a peer reconnects before its deadline (removed from the list) and when a cleanup tick actually deletes it.
func (*EphemeralPeersMetrics) IncPending ¶ added in v0.71.3
func (m *EphemeralPeersMetrics) IncPending()
IncPending bumps the pending gauge when a peer is added to the cleanup list.
type GRPCMetrics ¶
type GRPCMetrics struct {
// contains filtered or unexported fields
}
GRPCMetrics are gRPC server metrics
func NewGRPCMetrics ¶
NewGRPCMetrics creates new GRPCMetrics struct and registers common metrics of the gRPC server
func (*GRPCMetrics) CountGetKeyRequest ¶
func (grpcMetrics *GRPCMetrics) CountGetKeyRequest()
CountGetKeyRequest counts the number of gRPC get server key requests coming to the gRPC API
func (*GRPCMetrics) CountLoginRequest ¶
func (grpcMetrics *GRPCMetrics) CountLoginRequest()
CountLoginRequest counts the number of gRPC login requests coming to the gRPC API
func (*GRPCMetrics) CountLoginRequestBlocked ¶ added in v0.56.0
func (grpcMetrics *GRPCMetrics) CountLoginRequestBlocked()
CountLoginRequestBlocked counts the number of gRPC login requests from blocked peers
func (*GRPCMetrics) CountLoginRequestDuration ¶ added in v0.20.3
func (grpcMetrics *GRPCMetrics) CountLoginRequestDuration(duration time.Duration, accountID string)
CountLoginRequestDuration counts the duration of the login gRPC requests
func (*GRPCMetrics) CountSyncRequest ¶
func (grpcMetrics *GRPCMetrics) CountSyncRequest()
CountSyncRequest counts the number of gRPC sync requests coming to the gRPC API
func (*GRPCMetrics) CountSyncRequestBlocked ¶ added in v0.56.0
func (grpcMetrics *GRPCMetrics) CountSyncRequestBlocked()
CountSyncRequestBlocked counts the number of gRPC sync requests from blocked peers
func (*GRPCMetrics) CountSyncRequestDuration ¶ added in v0.20.3
func (grpcMetrics *GRPCMetrics) CountSyncRequestDuration(duration time.Duration, accountID string)
CountSyncRequestDuration counts the duration of the sync gRPC requests
func (*GRPCMetrics) RegisterConnectedStreams ¶
func (grpcMetrics *GRPCMetrics) RegisterConnectedStreams(producer func() int64) error
RegisterConnectedStreams registers a function that collects number of active streams and feeds it to the metrics gauge.
func (*GRPCMetrics) UpdateChannelQueueLength ¶ added in v0.23.5
func (metrics *GRPCMetrics) UpdateChannelQueueLength(length int)
UpdateChannelQueueLength update the histogram that keep distribution of the update messages channel queue
type HTTPMiddleware ¶
type HTTPMiddleware struct {
// contains filtered or unexported fields
}
HTTPMiddleware handler used to collect metrics of every request/response coming to the API. Also adds request tracing (logging).
func NewMetricsMiddleware ¶
NewMetricsMiddleware creates a new HTTPMiddleware
type IDPMetrics ¶
type IDPMetrics struct {
// contains filtered or unexported fields
}
IDPMetrics is common IdP metrics
func NewIDPMetrics ¶
NewIDPMetrics creates new IDPMetrics struct and registers common
func (*IDPMetrics) CountAuthenticate ¶
func (idpMetrics *IDPMetrics) CountAuthenticate()
CountAuthenticate ...
func (*IDPMetrics) CountCreateUser ¶
func (idpMetrics *IDPMetrics) CountCreateUser()
CountCreateUser ...
func (*IDPMetrics) CountDeleteUser ¶ added in v0.23.2
func (idpMetrics *IDPMetrics) CountDeleteUser()
CountDeleteUser ...
func (*IDPMetrics) CountGetAccount ¶
func (idpMetrics *IDPMetrics) CountGetAccount()
CountGetAccount ...
func (*IDPMetrics) CountGetAllAccounts ¶
func (idpMetrics *IDPMetrics) CountGetAllAccounts()
CountGetAllAccounts ...
func (*IDPMetrics) CountGetUserByEmail ¶
func (idpMetrics *IDPMetrics) CountGetUserByEmail()
CountGetUserByEmail ...
func (*IDPMetrics) CountGetUserDataByID ¶
func (idpMetrics *IDPMetrics) CountGetUserDataByID()
CountGetUserDataByID ...
func (*IDPMetrics) CountRequestError ¶
func (idpMetrics *IDPMetrics) CountRequestError()
CountRequestError counts number of error that happened when doing http request (httpClient.Do)
func (*IDPMetrics) CountRequestStatusError ¶
func (idpMetrics *IDPMetrics) CountRequestStatusError()
CountRequestStatusError counts number of responses that came from IdP with non success status code
func (*IDPMetrics) CountUpdateUserAppMetadata ¶
func (idpMetrics *IDPMetrics) CountUpdateUserAppMetadata()
CountUpdateUserAppMetadata ...
type MockAppMetrics ¶
type MockAppMetrics struct {
GetMeterFunc func() metric2.Meter
CloseFunc func() error
ExposeFunc func(ctx context.Context, port int, endpoint string) error
IDPMetricsFunc func() *IDPMetrics
HTTPMiddlewareFunc func() *HTTPMiddleware
GRPCMetricsFunc func() *GRPCMetrics
StoreMetricsFunc func() *StoreMetrics
UpdateChannelMetricsFunc func() *UpdateChannelMetrics
AddAccountManagerMetricsFunc func() *AccountManagerMetrics
EphemeralPeersMetricsFunc func() *EphemeralPeersMetrics
}
MockAppMetrics mocks the AppMetrics interface
func (*MockAppMetrics) AccountManagerMetrics ¶ added in v0.28.8
func (mock *MockAppMetrics) AccountManagerMetrics() *AccountManagerMetrics
AccountManagerMetrics mocks the MockAppMetrics function of the AccountManagerMetrics interface
func (*MockAppMetrics) Close ¶
func (mock *MockAppMetrics) Close() error
Close mocks the Close function of the AppMetrics interface
func (*MockAppMetrics) EphemeralPeersMetrics ¶ added in v0.71.3
func (mock *MockAppMetrics) EphemeralPeersMetrics() *EphemeralPeersMetrics
EphemeralPeersMetrics mocks the MockAppMetrics function of the EphemeralPeersMetrics interface
func (*MockAppMetrics) GRPCMetrics ¶
func (mock *MockAppMetrics) GRPCMetrics() *GRPCMetrics
GRPCMetrics mocks the GRPCMetrics function of the IDPMetrics interface
func (*MockAppMetrics) GetMeter ¶
func (mock *MockAppMetrics) GetMeter() metric2.Meter
GetMeter mocks the GetMeter function of the AppMetrics interface
func (*MockAppMetrics) HTTPMiddleware ¶
func (mock *MockAppMetrics) HTTPMiddleware() *HTTPMiddleware
HTTPMiddleware mocks the HTTPMiddleware function of the IDPMetrics interface
func (*MockAppMetrics) IDPMetrics ¶
func (mock *MockAppMetrics) IDPMetrics() *IDPMetrics
IDPMetrics mocks the IDPMetrics function of the IDPMetrics interface
func (*MockAppMetrics) StoreMetrics ¶ added in v0.20.3
func (mock *MockAppMetrics) StoreMetrics() *StoreMetrics
StoreMetrics mocks the MockAppMetrics function of the StoreMetrics interface
func (*MockAppMetrics) UpdateChannelMetrics ¶ added in v0.24.3
func (mock *MockAppMetrics) UpdateChannelMetrics() *UpdateChannelMetrics
UpdateChannelMetrics mocks the MockAppMetrics function of the UpdateChannelMetrics interface
type PeerStatusOperation ¶ added in v0.71.3
type PeerStatusOperation string
PeerStatusOperation labels the kind of fence-locked peer status write.
type PeerStatusOutcome ¶ added in v0.71.3
type PeerStatusOutcome string
PeerStatusOutcome labels how a fence-locked peer status write resolved.
type StoreMetrics ¶ added in v0.20.3
type StoreMetrics struct {
// contains filtered or unexported fields
}
StoreMetrics represents all metrics related to the Store
func NewStoreMetrics ¶ added in v0.20.3
NewStoreMetrics creates an instance of StoreMetrics
func (*StoreMetrics) CountGlobalLockAcquisitionDuration ¶ added in v0.20.3
func (metrics *StoreMetrics) CountGlobalLockAcquisitionDuration(duration time.Duration)
CountGlobalLockAcquisitionDuration counts the duration of the global lock acquisition
func (*StoreMetrics) CountPersistenceDuration ¶ added in v0.20.3
func (metrics *StoreMetrics) CountPersistenceDuration(duration time.Duration)
CountPersistenceDuration counts the duration of a store persistence operation
func (*StoreMetrics) CountTransactionDuration ¶ added in v0.33.0
func (metrics *StoreMetrics) CountTransactionDuration(duration time.Duration)
CountTransactionDuration counts the duration of a store persistence operation
type UpdateChannelMetrics ¶ added in v0.24.3
type UpdateChannelMetrics struct {
// contains filtered or unexported fields
}
UpdateChannelMetrics represents all metrics related to the UpdateChannel
func NewUpdateChannelMetrics ¶ added in v0.24.3
func NewUpdateChannelMetrics(ctx context.Context, meter metric.Meter) (*UpdateChannelMetrics, error)
NewUpdateChannelMetrics creates an instance of UpdateChannel
func (*UpdateChannelMetrics) CountCalcPeerNetworkMapDuration ¶ added in v0.50.0
func (metrics *UpdateChannelMetrics) CountCalcPeerNetworkMapDuration(duration time.Duration)
func (*UpdateChannelMetrics) CountCalcPostureChecksDuration ¶ added in v0.50.0
func (metrics *UpdateChannelMetrics) CountCalcPostureChecksDuration(duration time.Duration)
func (*UpdateChannelMetrics) CountCloseChannelDuration ¶ added in v0.24.3
func (metrics *UpdateChannelMetrics) CountCloseChannelDuration(duration time.Duration)
CountCloseChannelDuration counts the duration of the CloseChannel method
func (*UpdateChannelMetrics) CountCloseChannelsDuration ¶ added in v0.24.3
func (metrics *UpdateChannelMetrics) CountCloseChannelsDuration(duration time.Duration, channels int)
CountCloseChannelsDuration counts the duration of the CloseChannels method and the number of channels have been closed
func (*UpdateChannelMetrics) CountCreateChannelDuration ¶ added in v0.24.3
func (metrics *UpdateChannelMetrics) CountCreateChannelDuration(duration time.Duration, closed bool)
CountCreateChannelDuration counts the duration of the CreateChannel method, closed indicates if existing channel was closed before creation of a new one
func (*UpdateChannelMetrics) CountGetAllConnectedPeersDuration ¶ added in v0.24.3
func (metrics *UpdateChannelMetrics) CountGetAllConnectedPeersDuration(duration time.Duration, peers int)
CountGetAllConnectedPeersDuration counts the duration of the GetAllConnectedPeers method and the number of peers have been returned
func (*UpdateChannelMetrics) CountHasChannelDuration ¶ added in v0.24.4
func (metrics *UpdateChannelMetrics) CountHasChannelDuration(duration time.Duration)
CountHasChannelDuration counts the duration of the HasChannel method
func (*UpdateChannelMetrics) CountMergeNetworkMapDuration ¶ added in v0.50.0
func (metrics *UpdateChannelMetrics) CountMergeNetworkMapDuration(duration time.Duration)
func (*UpdateChannelMetrics) CountSendUpdateDuration ¶ added in v0.24.3
func (metrics *UpdateChannelMetrics) CountSendUpdateDuration(duration time.Duration, found, dropped bool)
CountSendUpdateDuration counts the duration of the SendUpdate method found indicates if peer had channel, dropped indicates if the message was dropped due channel buffer overload
func (*UpdateChannelMetrics) CountToSyncResponseDuration ¶ added in v0.50.0
func (metrics *UpdateChannelMetrics) CountToSyncResponseDuration(duration time.Duration)
type WrappedResponseWriter ¶
type WrappedResponseWriter struct {
http.ResponseWriter
// contains filtered or unexported fields
}
WrappedResponseWriter is a wrapper for http.ResponseWriter that allows the written HTTP status code to be captured for metrics reporting or logging purposes.
func WrapResponseWriter ¶
func WrapResponseWriter(w http.ResponseWriter) *WrappedResponseWriter
WrapResponseWriter wraps original http.ResponseWriter
func (*WrappedResponseWriter) Status ¶
func (rw *WrappedResponseWriter) Status() int
Status returns response status
func (*WrappedResponseWriter) WriteHeader ¶
func (rw *WrappedResponseWriter) WriteHeader(code int)
WriteHeader wraps http.ResponseWriter.WriteHeader method