// Put log events and update sequence token.
// Possible errors http://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_PutLogEvents.html
483277
func (prod *AwsCloudwatchLogs) upload(messages []*core.Message) {
	messages = prod.processBatch(messages)
	if len(messages) == 0 {
		return
	}
	logevents := make([]*cloudwatchlogs.InputLogEvent, 0, len(messages))
	for _, msg := range messages {
		logevents = append(logevents, &cloudwatchlogs.InputLogEvent{
			Message:   aws.String(msg.String()),
			Timestamp: aws.Int64(msg.GetCreationTime().Unix() * 1000),
		})
	}
	params := &cloudwatchlogs.PutLogEventsInput{
		LogEvents:     logevents,
		LogGroupName:  aws.String(prod.group),
		LogStreamName: aws.String(prod.stream),
		SequenceToken: prod.token,
	}
	prod.handleResult(prod.service.PutLogEvents(params))
}
507854
func (r *LogResponse) AddLog(log *bees.LogMessage) {
	r.logs = append(r.logs, log)
	r.Logs = append(r.Logs, prepareLogResponse(r.Context, log))
}
981592
func (f *ForwardingLog) AddForwardingEvents(events []ForwardingEvent) error {
	// Before we create the database transaction, we'll ensure that the set
	// of forwarding events are properly sorted according to their
	// timestamp.
	sort.Slice(events, func(i, j int) bool {
		return events[i].Timestamp.Before(events[j].Timestamp)
	})

	var timestamp [8]byte

	return f.db.Batch(func(tx *bbolt.Tx) error {
		// First, we'll fetch the bucket that stores our time series
		// log.
		logBucket, err := tx.CreateBucketIfNotExists(
			forwardingLogBucket,
		)
		if err != nil {
			return err
		}

		// With the bucket obtained, we can now begin to write out the
		// series of events.
		for _, event := range events {
			var eventBytes [forwardingEventSize]byte
			eventBuf := bytes.NewBuffer(eventBytes[0:0:forwardingEventSize])

			// First, we'll serialize this timestamp into our
			// timestamp buffer.
			byteOrder.PutUint64(
				timestamp[:], uint64(event.Timestamp.UnixNano()),
			)

			// With the key encoded, we'll then encode the event
			// into our buffer, then write it out to disk.
			err := encodeForwardingEvent(eventBuf, &event)
			if err != nil {
				return err
			}
			err = logBucket.Put(timestamp[:], eventBuf.Bytes())
			if err != nil {
				return err
			}
		}

		return nil
	})
}
890295
func (s *CreateBrokerRequest) SetLogs(v *Logs) *CreateBrokerRequest {
	s.Logs = v
	return s
}
869731
func (w *Webhook) UpdateEvent() error {
	data, err := jsoniter.Marshal(w.HookEvent)
	w.Events = string(data)
	return err
}
998135
func putData(c *cloudwatch.CloudWatch, metrics []cloudwatch.MetricDatum) (result *aws.BaseResponse, err error) {
	// Serialize the params
	params := aws.MakeParams("PutMetricData")
	for i, metric := range metrics {
		prefix := "MetricData.member." + strconv.Itoa(i+1)
		if metric.MetricName == "" {
			err = fmt.Errorf("no metric name supplied for metric: %d", i)
			return
		}
		params[prefix+".MetricName"] = metric.MetricName
		if metric.Unit != "" {
			params[prefix+".Unit"] = metric.Unit
		}
		if metric.Value != 0 {
			params[prefix+".Value"] = strconv.FormatFloat(metric.Value, 'f', -1, 64)
		}
		if !metric.Timestamp.IsZero() {
			params[prefix+".Timestamp"] = metric.Timestamp.UTC().Format(time.RFC3339)
		}
		for j, dim := range metric.Dimensions {
			dimprefix := prefix + ".Dimensions.member." + strconv.Itoa(j+1)
			params[dimprefix+".Name"] = dim.Name
			params[dimprefix+".Value"] = dim.Value
		}
		if len(metric.StatisticValues) == 1 {
			stat := metric.StatisticValues[0]
			statprefix := prefix + ".StatisticValues"
			params[statprefix+".Maximum"] = strconv.FormatFloat(stat.Maximum, 'f', -1, 64)
			params[statprefix+".Minimum"] = strconv.FormatFloat(stat.Minimum, 'f', -1, 64)
			params[statprefix+".SampleCount"] = strconv.FormatFloat(stat.SampleCount, 'f', -1, 64)
			params[statprefix+".Sum"] = strconv.FormatFloat(stat.Sum, 'f', -1, 64)
		}
	}
	result = new(aws.BaseResponse)
	err = query(c, "POST", "/", params, result)
	return
}
529406
func (ctrl *PersistentVolumeController) updateVolumePhaseWithEvent(volume *v1.PersistentVolume, phase v1.PersistentVolumePhase, eventtype, reason, message string) (*v1.PersistentVolume, error) {
	klog.V(4).Infof("updating updateVolumePhaseWithEvent[%s]: set phase %s", volume.Name, phase)
	if volume.Status.Phase == phase {
		// Nothing to do.
		klog.V(4).Infof("updating updateVolumePhaseWithEvent[%s]: phase %s already set", volume.Name, phase)
		return volume, nil
	}

	newVol, err := ctrl.updateVolumePhase(volume, phase, message)
	if err != nil {
		return nil, err
	}

	// Emit the event only when the status change happens, not every time
	// syncClaim is called.
	klog.V(3).Infof("volume %q changed status to %q: %s", volume.Name, phase, message)
	ctrl.eventRecorder.Event(newVol, eventtype, reason, message)

	return newVol, nil
}
481038
func (s *ApplicationUpdate) SetCloudWatchLoggingOptionUpdates(v []*CloudWatchLoggingOptionUpdate) *ApplicationUpdate {
	s.CloudWatchLoggingOptionUpdates = v
	return s
}
1307242
func (l SamplingEventLogger) Log(id EventID, e Event) {
	l.m.Lock()
	defer l.m.Unlock()

	r, ok := l.rootRates[id.Root]
	if !ok {
		r, ok = l.rates[e.Schema()]
	}

	if ok && r < l.r.Float64() {
		return
	}

	l.l.Log(id, e)
}
748528
func (tp *TokenPool) Put(t *Token) {
	tp.pool = append(tp.pool, t)
}
838537
func (bc *BlockChain) PostChainEvents(events []interface{}, logs []*types.Log) {
	// post event logs for further processing
	if logs != nil {
		bc.logsFeed.Send(logs)
	}
	for _, event := range events {
		switch ev := event.(type) {
		case ChainEvent:
			bc.chainFeed.Send(ev)

		case ChainHeadEvent:
			bc.chainHeadFeed.Send(ev)

		case ChainSideEvent:
			bc.chainSideFeed.Send(ev)
		}
	}
}
280794
func (s *Service) AddRunLog(ctx context.Context, taskID, runID influxdb.ID, when time.Time, log string) error {
	err := s.kv.Update(ctx, func(tx Tx) error {
		err := s.addRunLog(ctx, tx, taskID, runID, when, log)
		if err != nil {
			return err
		}
		return nil
	})
	return err
}
962645
func (l *Log) updateCommitIndex(index uint64) {
	l.mutex.Lock()
	defer l.mutex.Unlock()
	if index > l.commitIndex {
		l.commitIndex = index
	}
	debugln("update.commit.index ", index)
}
25461
func UpdateSpanWithErr(span opentracing.Span, err error) error {
	if err != nil {
		span.SetTag("error", true)
		span.LogFields(opentracinglog.String("event", err.Error()))
	}
	return err
}
539541
func (b *Build) PutRequest() (*v1.ApiPutRequestMessage, error) {
	tags := b.Tags.Copy()
	tags.Del(v1.TagBuilder) // buildbucket adds it automatically
	for _, bs := range b.Tags[v1.TagBuildSet] {
		if !tags.Contains(v1.TagBuildSet, bs) {
			tags.Add(v1.TagBuildSet, bs)
		}
	}

	msg := &v1.ApiPutRequestMessage{
		Bucket: b.Bucket,
		Tags:   tags.Format(),
	}

	parameters := map[string]interface{}{
		"builder_name": b.Builder,
		"properties":   b.Input.Properties,
		// keep this synced with marshaling error annotation
	}
	if data, err := json.Marshal(parameters); err != nil {
		// realistically, only properties may cause this.
		return nil, errors.Annotate(err, "marshaling properties").Err()
	} else {
		msg.ParametersJson = string(data)
	}

	return msg, nil
}
329397
func (s Server) setErrorAndLog(w *Response, responseError string, internalError error, debugFormat string, debugArgs ...interface{}) {
	format := "error=%v, internal_error=%#v " + debugFormat

	w.InternalError = internalError
	w.SetError(responseError, "")

	s.Logger.Printf(format, append([]interface{}{responseError, internalError}, debugArgs...)...)
}
1081614
func (e *RateLimitErrorLogging) AddEvents(ctx context.Context, points []*event.Event, next Sink) error {
	err := next.AddEvents(ctx, points)
	e.throttleLog(err)
	return err
}